heya, i cant figure out why my collision detection isn't working. im trying to make two objects merge into a new node like in suika game or 2048. I've followed a couple tutorials as well as tried using chatGPT to explain what i could be doing wrong but i cant figure it out. i have a rigid body parent node with a sprite and a collisionpolygon2d, i have connected the body entered signal and tried printing text to test the collision.
extends RigidBody2D
@export var node_value: int = 1
signal merged(new_node)
func _ready():
body_entered.connect(_on_body_entered)
func _on_body_entered3(body):
print("Body entered:", body)
func merge_with(other):
# Create a new node with the combined value
var new_node = preload("res://scenes/chipruby.tscn").instantiate()
new_node.node_value = node_value + 1
new_node.position = position.lerp(other.position, 0.5) # Place between the two nodes
emit_signal("merged", new_node)
func _on_body_entered(other):
if other is RigidBody2D and other.node_value == node_value:
merge_with(other)
# Free the old nodes
other.queue_free()
queue_free()