In a project I've been working on I have been trying to set up an 'aggro radius' for another entity in which a specific function will be ran if a certain body enters the radius.
In this scenario I have two entities:
A player with it's own collision shape in its tile.
An enemy with a large collision radius.
I have made sure that both of these CollisionShape2D's are on the same collision layer.
Within the enemy, attached to the Area2D (the aggro radius) I have this script:
extends Area2D
func _ready():
connect("body_entered", self, "_on_body_enter")
func _on_body_enter(body):
print("Test" + body.name)
Since the player's collision shape is a body I would assume that this would work but it doesn't. Is there anything extra I would need to do for this implementation?