Player Sprite Disappearing On Collision With Enemies Despite Health Remaining

Hey Guys, First time post here, thanks for providing so much help and advice, I cant imagine how lost beginner developers felt when they didn’t have access to all this information.

I have an issue where I have set player health to 500. As enemy lasers hit, doing damage of 100 a time, the health decreases as normal and reaching 0, destroys the player and loads game over scene.

However when I crash into an enemy sprite, the player sprite disappears completely. It removes 100 from my health but health is still at 400, so it isn’t game over, but the sprite has disappeared and the game play just continues without being able to have any input.

I feel like I should be able to suss this out, so moral is a little low at the moment, had a couple of days where my brain isn’t looking and organising the code properly, so I would appreciate the help to get past this problem for now.

Thanks!

1 Like

Hi and welcome to the community!

It’s kinda hard to help without seeing the code, Can you copy paste it here so we can see where the issue is? I looked at the Git of this lesson but found no issue that could cause this. Copy Paste the code where the player (or enemy) reads the collision.

1 Like

Hello and thanks for the quick reply!

I apologise for not posting the code in the first place, amateur! But I have realised the problem and I was right about myself not being on the ball the past couple of days.

I seemed to have completely forgot I could change the damage not only on the lasers and bombs, but also on the enemy themselves, referring to when the ship collides with another. I’ve set that damage to 500 so its an instant game over if you crash into another ship.

Feel pretty stupid but if this helps somebody else then I’m glad I posted.

Thanks for your time.

1 Like

Don’t feel stupid. We all make mistakes, and most of us are happy when they can find a solution online. Every thread with a problem and a solution, no matter how simple the problem might be, is a gain. :slight_smile:


See also:

2 Likes

I appreciate the kind words, no doubt you will be hearing from me again! :smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms