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