Page 1 of 1

second collision=destroying the actor

PostPosted: Sat Jan 14, 2012 4:40 am
by raminkhan
Hey guys i am trying to make my collided actor to stay alive with first collision but get destroyed with second collision how can I do that?

Re: second collision=destroying the actor

PostPosted: Sat Jan 14, 2012 4:57 am
by master0500
create a variable and name it, then in collision have
Code: Select all
myvar=myvar+1;
if (myvar==2)
{
    destroy actor function;
}

hope this helps

Re: second collision=destroying the actor

PostPosted: Sat Jan 14, 2012 5:53 am
by raminkhan
thanks bud but this did not work because when I putted this script in the script editor of the collision between two actors, the event actor the one who should get destroyed after second hit, gets destroyed with one collision.

Re: second collision=destroying the actor

PostPosted: Sat Jan 14, 2012 8:24 am
by foleyjo
Just gonna make a slight change to masters code just to show an alternativeand then try to get your problem resolved.

Change myvar to be hp (ie:hit points) . On the create of the Actor that should get destroyed after 2nd hit put

Code: Select all
hp = 2;


in the collision event do

Code: Select all
hp--;  //this is the same as hp = hp -1
if(hp<=0) DestroyActor;


Finally make sure repeat while this actor is colliding is set to No.