Enemy Movement Problem

Godot Version 4.2.2

Hey, me and my team are currently going insane about the enemy movement. The problem is that the enemy moves towards the player as soon as the player enters the detection area but always positions itself on the bottom right of the player and never comes closer than a few meters. How can we fix that?

Video Explanation: https://www.youtube.com/watch?v=S4UxImzR0YQ

You could try getting the enemy.distance_to(player) and having the enemy move toward the player until that distance reaches a threshold. How are you moving the enemy? Are you using a navigation agent?

Your enemy is likely created at an offset, make sure to create scenes at (0, 0) where the red and green line intersect. Otherwise it believes it’s position is above and to the left.

1 Like

How would I do that practically? How can I change my current scene to match those requirements?

Bad alignment


2024-07-12-125051_643x444_scrot Good alignment

1 Like

but wouldnt that just limit the possibilites of making a game in many ways? If I have to play every enemy on 0,0? Or did I just understand you wrong?

This is only when making component scenes. It’s about it’s children, the sprite2D, area and collision shapes, you can place the enemy anywhere.

Like gertkeno said, create a scene for the enemy and make sure its position is 0,0

Thank you so much, it worked, have a nice evening, you’re a hero!

I got burned by this several times when starting out! :smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.