Page 1 of 1
Health with cloned actors
Posted:
Thu Nov 23, 2006 2:13 am
by Zehper48
Hey is there an easy way or even a way at all to make a healthbar spawn for and enemy clone actor for example, if i have a smiley actor called creator that creates actor enemy,but i want the enemy to only be destoryed after 5 hits from actor bullet, can i do that
Posted:
Thu Nov 23, 2006 12:28 pm
by makslane
Create a variable lives (Actor, integer).
Actor variables are not global, so, if you have a clone with lives = 3, you can have other with lives = 1.
Posted:
Thu Nov 23, 2006 11:14 pm
by Zehper48
do variables work like textNumbers
whats the code to make a variable go down if a bullet hits it
Posted:
Thu Nov 23, 2006 11:39 pm
by makslane
In a Collision event, put a script like this:
- Code: Select all
lives--;
if(lives <= 0)
{
//You are dead!
}
Posted:
Fri Nov 24, 2006 2:47 pm
by Zehper48
im trying to make a bad guy that i can clone but im not used to useing variables.
on actor "badguy" i added this to draw actor
- Code: Select all
if(badguylives <=-1)
{
DestroyActor("Event Actor");
}
then on collison with actor "redassultleft"
- Code: Select all
badguylives - 1;
but actor "badguy" wont die
Posted:
Fri Nov 24, 2006 6:19 pm
by Hedfone
try, on create actor of enemy, something like:
- Code: Select all
badguylives = //the desired number of shots to kill;
this might work but I'm god awful with coding so I'm not sure
Posted:
Fri Nov 24, 2006 8:38 pm
by Zehper48
ok i added that too but the bad guy wont be destroyed! i dont know what to do
Posted:
Fri Nov 24, 2006 9:10 pm
by Hedfone
think I found it,
on collision with redassaultleft the code SHOULD be
- Code: Select all
badguylives -=1//updates every shot
or
- Code: Select all
badguylives=badguylives-1;//updates every shot
not
- Code: Select all
badguylives = -1;//simply tells the comp the value
the first and second one will update the health every shot. the third one tells the comp that you want the lives of the enemy to be -1 when the enemy collides on the bullet
and on that draw actor event, change
- Code: Select all
if (badguylives <=-1)
to
- Code: Select all
if (badguylives <=0)
REALLY hope this has helped. good luck
Posted:
Sat Nov 25, 2006 2:42 am
by Zehper48
yes i got it working the bad guy dies! Thanks man for helping me you deserve a medal!!!!!
i changed the code from badguylives-1; to badguylives=badguylives-1; and it worked, now i can continue my game
Posted:
Sat Nov 25, 2006 5:11 pm
by Hedfone
Great
I'm happy I could help