Switched to 4.3 from 4.2 and now punch is broken

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

1 Like

The code seems fine. Are the collision layer and mask set up correctly?
You could also adapt the 4.x way of emitting signals:

SignalBus.on_health_changed.emit(get_parent(), value-health)
1 Like

You may need to reconnect the signals from the signal tab.

2 Likes

I checked and the layer and mask are set up and ill be sure to try the way you suggested of emitting signals

Will try thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.