godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.14k stars 20.2k forks source link

In a Navigation Map created programmatically, velocity_computed()->safe_velocity is always 0 #81859

Closed venilark closed 1 year ago

venilark commented 1 year ago

Godot version

4.1.1

System information

Windows 10

Issue description

If I create a navigation map at runtime, by setting up the navigation mesh, region and everything and then assign that map to the NavigationAgent3D, velocity_computed always returns 0. Doesn't happen with the basic prebaked navigationmesh.

Steps to reproduce

Run both scenes. NavigationTestPrebaked works just fine, Agent walks towards the destination. NavigationTestRuntime does nothing, despite query_path() returning a valid path so the RID is working.

Minimal reproduction project

test_velocity_computed.zip

smix8 commented 1 year ago

The issue in the test project is that a NavigationAgent3D node has no target_position set. The NavigationAgent is only used for avoidance in the test project which is fine but it still needs a target_postion set to process.

This was added because so many users forgot to set a target_position but activated everything else which would make the NavigationAgents move towards the world origin.

If you set the velocity with the NavigationServer3D API using NavigationServer3D.agent_set_velocity() bypassing all those checks on the NavigationAgent node everything works fine.

smix8 commented 1 year ago

Closing the issue as it was confirmed solved on Discord by user.