0 votes

I have a Level scene with a sprite of the map. I'm adding instances of an enemy scene in a node in this Level scene. I want to make an enemy move to a point (player or other enemies) without colliding with other stuff and I only want to make them to move horizontally or vertically.

Enemies spawn in random positions in the Level scene, but only in a specific rectangle area. I want them to move 16 pixels to the direction it needs, to another empty space until they reach their destination.


Level scene and Nodes: https://imgur.com/JzAkU7H

in Engine by (12 points)

1 Answer

+2 votes

Godot has a built-in implementation of the A* algorithm, which is commonly used to calculate the shortest distance between two locations.

If you only generate connections between adjacent points it will not suggest diagonal moves. This is a pretty good tutorial video:


by (866 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.