0 votes


I'm having some trouble with a Navigation2D on a tilemap. I've attached a screenshot showing what I'm attempting. (green squares passable, red not).

The first thing that happens is both the enemy and the player snap to the center of the grid square they are in (the yellow dot). Then, I call the getsimplepath function on the Navigation2D for the bat to work its way to the player.

On screenshot 1 it's mostly okay, but it stops short and never reaches the player.

On screenshot 2, the first thing it does it goes to the left, then goes right and follows the path as it should, stopping within range of the player. I'm not sure why it makes this initial move to the left, as there is no route in that direction. For a bit of context, this is the position of the bat after it has snapped to the center of it's grid square:
(176, 16)

and this is the path it is generating following that:

[(160, 16), (192, 16), (208, 32), (208, 64), (208, 96), (192, 112), (160, 112), (144, 96), (128, 80), (96, 80)]

It's the 160, 16 that makes no sense. I would have thought it should be going for 192, 16 first?

Hopefully this makes sense and someone can advise. I wondered if it had something to do with the snapping I'm doing in the ready function, but taking that out doesn't seem to fix it.

Yellow - snap position, red - path

Godot version 3.2.3
in Engine by (12 points)
edited by

Please log in or register to answer this question.

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.