Page 1 of 1

Collisions

PostPosted: Fri Jul 15, 2011 6:25 am
by MilloCz
Okay hi, i have many different actors such as door (openable), moving platforms, springs, tileset ... how do i make player collide them all? Is't there any other way how to collide all models except backround or backround tileset?

Re: Collisions

PostPosted: Fri Jul 15, 2011 7:11 am
by skydereign
Generally speaking, no. You'd have to create collision events with all of them. Though, depending if you find this acceptable (generally a bad idea) you could have a collision event with every actor, and then use something like this to determine what actions to take.
player -> Collision with Any Actor -> Script Editor
Code: Select all
if(strcmp(collide.name, "door")==0)
{
    // collide with door event code
}
else if(strcmp(collide.name, "wall")==0)
{
    // etc
}

Re: Collisions

PostPosted: Fri Jul 15, 2011 8:40 am
by lcl
Sky, it's actually:
Code: Select all
if (strcmp(collide.name, "door") == 0)
{
    //...
}

Because strcmp returns 0 if strings are same, not 1. :)

Re: Collisions

PostPosted: Fri Jul 15, 2011 9:06 am
by skydereign
Yeah, accidentally mixing my metaphors. I usually use an actor variable to do that, so I forgot to add the ==0. In fact I might as well suggest that here. I usually create an actor variable type that I set in every important actor's create actor event. That way, in collisions and whatnot I can tell what actor type without having to use strcmp. This makes it generally easier to deal with and more efficient, and can be used in this case.