Page 1 of 1

Specify a group and take action?

PostPosted: Wed Apr 25, 2012 6:06 pm
by Hblade
I'd like to know if it's possible to specify a "group type", something like for example, uh.. in create actor

Code: Select all
actorType=wall;


And then Collision - Any Actor - Script Editor
Code: Select all
if(collider.actorType==wall)
{
    //code
}


This way I wont have to keep adding physical response codes and whatnot, so if I wanted to add a moving platform I'd simply add actorType=wall to the script.

This would also come in handy for other things too


something tells me the answer is right in my face... lol

Re: Specify a group and take action?

PostPosted: Wed Apr 25, 2012 6:37 pm
by skydereign
I do this with enemy actors and collisions sometimes. You need to use any actor for your collision event.

Re: Specify a group and take action?

PostPosted: Thu Apr 26, 2012 8:54 pm
by Hblade
Thanks

Re: Specify a group and take action?

PostPosted: Fri Apr 27, 2012 4:21 am
by NightOfHorror
So wait, would that make you able to specify that it is a wall in its create actor and instead of adding new code to the other actors, you just put in that and it is done in one simple code. :)

Re: Specify a group and take action?

PostPosted: Fri Apr 27, 2012 2:39 pm
by Hblade
By using an actor variable called wall, collider.wall means what ever the collision actor is cliding with, so it'd be like this:
Code: Select all
switch((int)collider.wall) //(int) for safty reasons? I haven't tested this yet
{
    case 0: //no wall
    //dont collide
    break;
    case 1: //wall
    //physical response, code, etc
    break;
}



or just use if(collider.wall==1)
{
code
}

Re: Specify a group and take action?

PostPosted: Fri Apr 27, 2012 3:55 pm
by skydereign
In general though, you can use a single actor variable for many different types. So if you name it type, or similar, you can use it for more than just walls.

Re: Specify a group and take action?

PostPosted: Fri Apr 27, 2012 7:22 pm
by Hblade
True! :P Wans't thinking outside the box hehe

Re: Specify a group and take action?

PostPosted: Fri Apr 27, 2012 8:44 pm
by NightOfHorror
so you could divide it up into perhaps, weapon collisions, or even canvas?

Re: Specify a group and take action?

PostPosted: Sat Apr 28, 2012 9:02 am
by Hblade
Sure can =)