Godot Version
4.3
Question
So when i switched from 4.2 my punch broke and i cant figure out why
My code had a code to do the damage on area 2D
extends Area2D
@export var damage : int = 1
func _on_body_entered(body):
for child in body.get_children():
if child is Damageable:
child.hit(damage)
and a player body 2d that is supposed to receive the damage from the punch collision but it does nothing
extends Node
class_name Damageable
@export var health : float = 1:
get:
return health
set(value):
SignalBus.emit_signal("on_health_changed", get_parent(), value - health)
health = value
func hit(damage: int):
health -= damage
if(health <= 0):
get_parent().queue_free()
And i have tried with the layers but the character works with another collision in the same scene on the same layer but the enemy does not get affected by the punch