V
VicoZann
Guest
So I'm setting up the damage and destruction functions for the enemies in my game, starting with the all powerful metal box. I want to kill this box. And I can kill the box. But that's the problem.
if(place_meeting(x,y,parent_hitbox))
{
hp -= parent_hitbox.damage;
}
if(hp <= 0)
{
instance_destroy();
}
I attack, generate the hitbox, it touches the box and the box takes damage and dies. But the damage doesn't stop reducing it's HP until the box dies. If I hit it with the punniest attack ever, it will still drain it's HP until it's destroyed.
The hitbox for the attacks only lasts 1 frame, but I suppose that there's nothing coded telling the hp -= code to stop reducing the HP. I'm just not sure how exactly I show go about to fixing this
I searched for tutorials online, namely Heartbeast's and Shaun Spalding's but both of them, as far as I understood, arranged the damaging script in a similar way to mine, so, why doesn't the damage stops damaging after the hitbox disapears?
=============================
Edit
============================
With more testing, I noticed yet another problem. I have a parent hitbox object that is the one responsible for destroying the hitboxes and many other child hitboxes each with their own damage and shape, for different attacks. But for some reason the first attack I use in a room will make every other hitbox have the same damage, so if I use a strong attack and then a weak one, the weak will do the same damage as the strong
if(place_meeting(x,y,parent_hitbox))
{
hp -= parent_hitbox.damage;
}
if(hp <= 0)
{
instance_destroy();
}
I attack, generate the hitbox, it touches the box and the box takes damage and dies. But the damage doesn't stop reducing it's HP until the box dies. If I hit it with the punniest attack ever, it will still drain it's HP until it's destroyed.
The hitbox for the attacks only lasts 1 frame, but I suppose that there's nothing coded telling the hp -= code to stop reducing the HP. I'm just not sure how exactly I show go about to fixing this
I searched for tutorials online, namely Heartbeast's and Shaun Spalding's but both of them, as far as I understood, arranged the damaging script in a similar way to mine, so, why doesn't the damage stops damaging after the hitbox disapears?
=============================
Edit
============================
With more testing, I noticed yet another problem. I have a parent hitbox object that is the one responsible for destroying the hitboxes and many other child hitboxes each with their own damage and shape, for different attacks. But for some reason the first attack I use in a room will make every other hitbox have the same damage, so if I use a strong attack and then a weak one, the weak will do the same damage as the strong
Last edited by a moderator: