#NavigationAgent2D safe_velocity not computing correctly

20 messages · Page 1 of 1 (latest)

spice relic
#

Avoidance is enabled, signal is connected, default parameters, navigationPolygonInstance is created and object is in it
nextPoint is navAgent's get_next_location().
If i dont use velocity_computed, set_velocity and update velocity in the set_direction method navigation works perfectly, but i need to implement obstacle avoidance.
Have not tried any other navigation algorithm.

would appreciate any help

viscid belfry
#

@spice relic how did you get the set_velocity to activate velocity_computed?

spice relic
#

Hey @viscid belfry .
set_velocity 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.
(From the docs)

viscid belfry
spice relic
#

You have to enable the avoidance on the agent

viscid belfry
#

something that im missing?

spice relic
#

Hm, i dont know about 3d navigation and agents or if its any different, but are you sure that youre connecting the velocity_computed signal?

#

those are the main points: call set_velocity on navAgent, connect the velocity_computed signal from navAgent, do your logic in that method. And make sure that the original method is being called?

#

Although my problem still persists, where the safe_velocity is not computed correctly

viscid belfry
spice relic
#

sorry for not being clear. Yes, it outputs a value, but it is not correct. For some weird reason it stays the same throughout the whole navigation, which makes the object just move in a straight line

#

Although, if i dont use the safe velocity computation on navAgent, then the navigation works perfectly

#

Really stumped on this, even considering dropping it for now 😕

viscid belfry
spice relic
#

I just have a simple navigationPolygonInstance and the object is wandering randomly in it. If it encounters wall then it goes around it.

But the last part works ok, its not proper avoidance just polygon manipulation. Thats why i want to add the safe velocity computation, so it could properly avoid anything.

viscid belfry
#

so nextPoint is just a randomly generated point

#

and it can calculate to normalVelocity to get there but not the avoidance

#

correct?