How to make the body lose health, but not the areas inside?

Godot 4.3

Hello! I am currently working on a project 2D shoot em up game with a healthbar. My healthbar worked fine, but once i shot any bullets at the enemy, my health decreased too, how do I make only my CharacterBody2D affect my health when touching the enemy, but not my attacking areas inside it?

Code:

func set_health_label() → void:
$HealthLabel.text = “Health: %s” % health

func set_health_bar() → void:
$HealthBar.value = health
func _on_punching_bag_area_entered(area) → void:
damage()

func damage() → void:
health -= 1
if health < 0:
get_tree().reload_current_scene()
set_health_label()

If anyone could help me out with this I would greatly appreciate it. I’ve tried a lot and this was one of my last resorts. Thank you if you do end up solving my problem

It sounds like you bullet is hitting your player character too.

You can try using tags for your game pieces. Defining or attaching a script with a string in it that you can read. This string is your tag telling the bullet if it’s ‘enemy’ or ‘player’

1 Like

ok thanks alot!