Collisions

Non-platform specific questions.

Collisions

Postby MilloCz » Fri Jul 15, 2011 6:25 am

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?
MilloCz
 
Posts: 9
Joined: Mon Jul 11, 2011 5:38 pm
Score: 0 Give a positive score

Re: Collisions

Postby skydereign » Fri Jul 15, 2011 7:11 am

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
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collisions

Postby lcl » Fri Jul 15, 2011 8:40 am

Sky, it's actually:
Code: Select all
if (strcmp(collide.name, "door") == 0)
{
    //...
}

Because strcmp returns 0 if strings are same, not 1. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Collisions

Postby skydereign » Fri Jul 15, 2011 9:06 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest