Godot Version
4.5.1
Question
When the enemy approaches the player especially from above it gets stuck against the player top right It keeps pushing and never separates Increasing stop distance doesnt help
Setup: Player is CharacterBody2D with Capsule CollisionShape2D Enemy is CharacterBody2D with NavigationAgent2D moving toward player global_position Enemy uses move_and_slide and avoidance Enemy also uses Capsule CollisionShape2D
navigation_agent_2d.target_position = player.global_position
if navigation_agent_2d.is_navigation_finished():
velocity = Vector2.ZERO
move_and_slide()
return
var next_path_position = navigation_agent_2d.get_next_path_position()
var new_velocity = global_position.direction_to(next_path_position) * movement_speed
if navigation_agent_2d.avoidance_enabled:
navigation_agent_2d.set_velocity(new_velocity)
else:
_on_navigation_agent_2d_velocity_computed(new_velocity)
move_and_slide()
