Calculating damage calculation in game loop
Your problem isn't you calculating damage on the collision method (though i think it's wrong); I think you problem is that the OneEyeSkillSlash collides with your ship through various frames, making your ship life decrease rapidly.
So you have some options.
- Destroy the OneEyeSkillSlash after a hit.
- Make your OneEyeSkillSlash not be able to damage again the ship.
- Make your ship invincible for a short time after being hit.
- Implement some other mechanic.
Your problem isn't you calculating damage on the collision method (though i think it's wrong); I think you problem is that the OneEyeSkillSlash collides with your ship through various frames, making your ship life decrease rapidly.
So you have some options.
- Destroy the OneEyeSkillSlash after a hit.
- Make your OneEyeSkillSlash not be able to damage again the ship.
- Make your ship invincible for a short time after being hit.
- Implement some other mechanic.
Ah yes, that is correct. It is checking every frame!
Thank you. I know what to do now.