+1 vote

I am trying to make an isometric game with AI that path-finds its way to its food source. Right now, the path-finding algorithm is not working. The AI is the blue sphere with 7 dark blue stumps for feet, it moves similar to a wheel. Its food source is the red one, but the image is just a placeholder.
enter image description here
This is the nav mesh collision, I only placed the collision on the green part of the 1st tile as its the only one the entity can step on. Its cut around the corners to prevent the entity from stepping on one edge of a tile to the other. The other tiles are meant to be obstacles.
enter image description here
This is the script

extends KinematicBody2D

var speed = 150
onready var nav = get_parent().get_node("Nav")
var path = []
onready var goal = get_parent().get_node("RedGhola").get_global_position()

func _ready():
set_physics_process(true)
update_path()

func update_path():
path = nav.get_simple_path(get_position(),goal,false)

func _physics_process(delta):
if path.size() > 1:
    var d = get_position().distance_to(path[0])
    if d > 2:
        set_global_position(get_global_position().linear_interpolate(path[0], (speed*delta)/d))
    else:
        path.remove(0)

The 'getsimplepath' returns null.
I am not planning on using the Astar method as the map can get big, really big, like a 40 by 40, and the entity should not find food from one side to another, it should only find it a maximum of 8 tiles. If however it cannot find food, it will move randomly in one of the 4 directions. I started in Godot for a week and am a fresh IT graduate (2 months).

in Engine by (26 points)

1 Answer

0 votes

Nevermind, I managed to have the pathing work, I forgot to re-export the tileset when I made the change in the tileset.

by (26 points)

Hi @rabbitsme

Could you share this sample?
I`m trying to achieve the same thing, but my path is always empty array.
I did the isometric Polygon but nothing happens

enter image description here

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.
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 webmaster@godotengine.org with your username.