second collision=destroying the actor

Non-platform specific questions.

second collision=destroying the actor

Postby raminkhan » Sat Jan 14, 2012 4:40 am

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?
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: second collision=destroying the actor

Postby master0500 » Sat Jan 14, 2012 4:57 am

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
master0500
 
Posts: 409
Joined: Sun Jun 26, 2011 9:42 pm
Score: 27 Give a positive score

Re: second collision=destroying the actor

Postby raminkhan » Sat Jan 14, 2012 5:53 am

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.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: second collision=destroying the actor

Postby foleyjo » Sat Jan 14, 2012 8:24 am

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.
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest