+3 votes

How do i change a navpoly in the code during runtime?

I use the 2d demo, navpoly as an example. The following code is expected in the navpoly example to make the sprite stop completly since whole polygon is remove, but it doesn't.

var navpoly = get_node("Navigation2D/NavigationPolygonInstance").get_navigation_polygon()
navpoly.clear_polygons()
get_node("Navigation2D/NavigationPolygonInstance").set_navigation_polygon(navpoly)

I would like to remove or add parts of the polygon so the path is changed dynamicly.
EDIT: Actually, all changes to the navpoly with the set_navigation_polygon seems to stop the navigation. What am I doing wrong?

in Engine by (29 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.