I'm using godot 4.2.1 and try to orient this tutorial series in my first test project.
I made a map and common enemy which is inherited form base enemy and walks on a path. Also I made a TowerMk1 inherited from base tower. Now I want this tower to rotate and track enemies in it's range.
My problem is that body_entered signal of tower's Area2D doesn't trigger.
My BaseEnemy:
My CommonEnemy (pink rectangle - CollisionShape2D):
BaseTower:
TowerMk1 (blue circle - CollisionShape2D):
body_entered is connected in BaseTower in the editor - proof:
In TowerMk1 it's connected automatically because of an inheritance.
BaseTower script:
extends Node2D
@export var enemy_tracking : bool = true
var enemies = []
func _physics_process(delta):
if enemy_tracking:
track_enemy()
else:
pass
func track_enemy():
var target = select_enemy()
if not target == null:
turn_to(target)
func select_enemy():
var max_progress = -1
var target
var current_progress
for enemy in enemies:
current_progress = enemy.get_progress()
if current_progress > max_progress:
target = enemy
max_progress = current_progress
return target
func turn_to(target):
get_node("TowerSprite").look_at(target.position)
func _on_range_body_entered(body):
if body is BaseEnemy:
enemies.append(body.get_parrent())
func _on_range_body_exited(body):
if body is BaseEnemy:
enemies.erase(body.get_parrent())
I put a debugger stop flag on this row:
But it is not triggered at all!
I marked a checkbox to show collision shapes during a debug and this is how it looks:
You can see that the pink rectangle is inside the blue circle (it was not spawned right here - they traveled from the beginning of the path). But the collision was not triggered.
Collision of both Range of the tower and AnimatebleBody2D of the enemy match in their parameters: Layer 1, Mask 1.
What do I do wrong?






