• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Health

H

HenrikDK

Guest
I'm trying to use a very small amount of events, and it's a bit hard with the small amount of programming knowledge that i have... I made a variable saying this character have 2 health;", if a collision with obj_bullet is detected, destroy object bullet and - 1 health of this character. If the character have a health number equal to 0 or lower, destroy object..

Create:
///Variables
enemyhp=2;

Step:

if (enemyhp <= 0)
{
instance_destroy();
}

if place_meeting(x,y, obj_bullet)
{
enemyhp -= 1;
}

if place_meeting(x, y, obj_player)
{
instance_destroy();
}
 
W

Wild_West

Guest
If your enemy is being destroyed instead of the bullet, you just need to do a with(obj_bullet) then instance_destroy();
 
H

HenrikDK

Guest
The bullet is being destroyed, no problem with that... It's just the enemy that is not taking damage.
 
W

Wild_West

Guest
The bullet is being destroyed, no problem with that... It's just the enemy that is not taking damage.

Oh, is the above code in the enemy step event? Because if the bullet IS being destroyed without a with statement I would assume this is in te bullet object.
 

JasonTomLee

Member
Or you could try adding the collision in the bullet~
Code:
if (place_meeting(x+ hspeed,y+ vspeed, obj_enemy){
with(obj_enemy){
hp-=1;
}
}
You need to make sure the bullet doesnt skip over the target if its moving too fast
 
H

HenrikDK

Guest
If your enemy is being destroyed instead of the bullet, you just need to do a with(obj_bullet) then instance_destroy();
The bullet dosen't skip over the object, because it get destroyed before it get out on the other side..

I solved it, it was a conflict with another script, that destroyed the bullet before the other script could read..
 
Top