I’m trying to debug why avoidance doesn’t seem to work with Godot’s 2D navigation tutorial example code.
The documentation in Godot for NavigationAgent2D
’s avoidance_enabled
property states:
If
true
the agent is registered for an RVO avoidance callback on theNavigationServer2D
. Whenset_velocity()
is used and the processing is completed asafe_velocity
Vector2
is received with a signal connection tovelocity_computed
. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
set_velocity()
reads:
Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the
velocity_computed
signal.
velocity_computed
reads:
Notifies when the collision avoidance velocity is calculated. Emitted at the end of the physics frame in which
set_velocity()
is called. Only emitted whenavoidance_enabled
is true.
So it seems that the collision avoidance is not happening because the example navigation code sets the velocity directly without telling the navigation agent.