Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mateu |
Hi Godot bros, I made a room with a tilemap adding navigation to the tiles. I have an enemy that follows the player using the navigation. If the room I place the room in the origin coordinates 0,0 everything works fine, the problem comes when I move it. The enemy only moves in the zone that would be the room if it was in the origin coordinates
navigation.get_simple_path(global_position, player.position)
I get the path with this function, I use the local player position because the player is a direct child of the main scene, the local and global coordinates are the same.
var distance_to_next_point: float = (path[0] - global_position).length()
if distance_to_next_point < 1:
path.remove(0)
if not path:
return
var direction: Vector2 = path[0] - global_position
mov_direction = direction
I use this code to follow the path and I move it with the move_and_slide()
function.
Maybe the problem is something with the local and global coordinates?
Help me, please!