Specify a group and take action?

Non-platform specific questions.

Specify a group and take action?

Postby Hblade » Wed Apr 25, 2012 6:06 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Specify a group and take action?

Postby skydereign » Wed Apr 25, 2012 6:37 pm

I do this with enemy actors and collisions sometimes. You need to use any actor for your collision event.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Specify a group and take action?

Postby Hblade » Thu Apr 26, 2012 8:54 pm

Thanks
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Specify a group and take action?

Postby NightOfHorror » Fri Apr 27, 2012 4:21 am

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. :)
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: Specify a group and take action?

Postby Hblade » Fri Apr 27, 2012 2:39 pm

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
}
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Specify a group and take action?

Postby skydereign » Fri Apr 27, 2012 3:55 pm

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

Re: Specify a group and take action?

Postby Hblade » Fri Apr 27, 2012 7:22 pm

True! :P Wans't thinking outside the box hehe
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Specify a group and take action?

Postby NightOfHorror » Fri Apr 27, 2012 8:44 pm

so you could divide it up into perhaps, weapon collisions, or even canvas?
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: Specify a group and take action?

Postby Hblade » Sat Apr 28, 2012 9:02 am

Sure can =)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron