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

asked Jun 28 in Engine by viniciused26 (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:


answered Jun 28 by JimArtificer (852 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 How to use this Q&A? before posting your first questions.