How to make a health system?

Hello! I’ve been working on a little 2d platformer, nothing much but I wanna add something where if I get touched by my “hurtzone” (creative), it’ll… well… hurt me till I eventually died. Everything I’ve tried on my own hasn’t worked and tutorials haven’t either so I’m just wondering, how would you guys make this? I don’t have any code since this is more of a general question than a fix me up you know?

Things that interact have a collision shape.

In everything that can be damaged I define a take_damage method.

Everything that causes damage has a check like this when a collision happens:

if body.has_method("take_damage"):
		body.take_damage(damage_done)
1 Like

You get hurt by your own hurtbox?

I would start with checking if the body

if body != self:

Add previous code below, indented

I guess s/he meant hurtzone,like a bluezone in PUBG.

1 Like