func _physics_process(delta):
var enemies_in_range = get_overlapping_bodies()
if enemies_in_range.size() > 0:
var target_enemy = enemies_in_range.front().global_position
for enemy in enemies_in_range:
if enemy is Node2D:
var enemy_position = enemy.global_position
var distance = position.distance_to(enemy_position)
if distance < position.distance_to(target_enemy):
target_enemy = enemy_position
look_at(target_enemy)```
#Enemys "sticking" to player? also nearest to player script not really working
9 messages · Page 1 of 1 (latest)
this is the bullet script
You wanna make sure your Characterbody Motion Mode is set to Floating instead of grounded, since this is a top-down game rather than a platformer
And try global_position...
Instead of position...
in your script not only for the enemies
the script fix worked but the enemies still sometimes stay with the character
Mhm weird, these enemies stuck to the player should be shot and killed right?