Best way to make the player receive damge?

Godot Version



I’m just trying to know a better way to make the player receive damage because the way I set up this has some problems.

so the way I have this is the enemy emits a signal in the player to let him know that it receives damage, it works fine and if I want the player not to receive damage I just set to true a variable that prevents the damage to be receive, the problem whit this is that even if the player doesn’t receive damage the enemy still collides whit the player and for this to not happen I have to change the collision mask in the enemy which can be achieved by emitting a signal in the enemy when I make the player not receive damage but this doesn’t seem right for me.

so is there a better way to send damage or should I make the player receive the damage when colliding with the enemy?


Captura de pantalla 2024-02-08 132704

Thanks in advance and sorry if what I want to say is not understandable.

If you want the player to not collide when she’s been damaged, why not just change the player’s collision mask instead of the enemy’s?

1 Like

Because the way i have set up the enemy is the one emitting the signal in the player, so even if i change the player collision mask the enemy still detects the player and still collides whit it, unless you are referring to changing the layer but that generates a bunch of other problems.

thanks for the answer

I don’t know what you want to accomplish. In a given frame two objects either collide or don’t, and you are in control of that. That has nothing to do with damage. You can change the enemy behaviour at the same time you send the signal too. I don’t understand where the problem is.