getting health and death animation working

C

crazybloodmonkey

Guest
so i have been having problem with my character's health and dying animation i got the health to work but every time i got hit by the bullet it would the dying animation so it was like i was dying three time before i actually died. someone told make state machines in my step event and i tried that but it didn't really work so maybe someone could show me what i did wrong or what i should do.

obj_player
Code:
switch (state) {
case state.death:
{
if hp <= 0 = state = state.death
instance_change(obj_death,true)
instance_destroy()
}}


then in obj_ebullet there a collison with object player and this coded in it
code:
obj_player.hp -= 1
 
A

Aura

Guest
You're over-complicating things by using a state for death. Since you are going to change the instance into an instance of another object, you should keep death apart from rest of the states.

Code:
if (hp <= 0) {
   instance_change(obj_Dead, true);
}
That should do what you want. Since you're changing the instance into an instance of obj_Dead, you don't need to call instance_destroy() either.

But if you want to go about using states then please post all the relevant code; the code snippet that you have posted is not sufficient.
 

MusNik

Member
I'd recommend you not to use different objects for different states of player. Change sprite and behaviour in your state switch instead of it.
 
C

crazybloodmonkey

Guest
You're over-complicating things by using a state for death. Since you are going to change the instance into an instance of another object, you should keep death apart from rest of the states.

Code:
if (hp <= 0) {
   instance_change(obj_Dead, true);
}
That should do what you want. Since you're changing the instance into an instance of obj_Dead, you don't need to call instance_destroy() either.

But if you want to go about using states then please post all the relevant code; the code snippet that you have posted is not sufficient.
someone on the reddit forum already solve the problem but i appreciate your help
 
Top