The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Running Godot 3.0.6 w/ Godotsteam

I've been looking at a problem for a little while and I'm a bit stumped. I've got these buildings with collision polygons and I subtract them from the Navigation2d nav mesh. Those polygons show as red boxes in the gif. I then just do getsimplepath with the mouse click event position and it all works great. Except for these edge cases where the user clicks the on the other side of a building. It goes the long way around. I've got the optimizing enabled, not much else in the way of options.

Going the wrong way around in a nav mesh gif

Code is pretty simple, just takes mouse event as destination.

if event.button_index == BUTTON_LEFT and event.pressed:
    mousepos = get_global_mouse_position() - Vector2(0, spriteheight / 4) + mousecursordif
    update_navigation_path(global_position, mousepos)

func update_navigation_path(startpos, endpos):
    navinst = get_tree().get_nodes_in_group('activenav')[0]
    navpath = navinst.get_simple_path(startpos, endpos, true)

Movement is just linear interp between navpath points. Printing out the navpath shows a series of points going the wrong way around. I figure it's something silly i'm doing wrong, but I'm having a hard time figuring it out. Anyone seen this before?

in Engine by (21 points)

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.