Support Forum

Turn before I move

Hello Aron, I am already in a very advanced phase to be able to finish implementing your system in my project, I need to implement the rotation before moving to a new destination, my idea is if the agent is below 11.5º between the destination and the agent can walk, otherwise must turn without walking. How can I do this in the best way? in this wiki it explains in more detail my intention:,make%20a%20180%20degree%20turn.

I am running this function to check if it can start the path:
if (RotateBackward(destinationTarget))
{ = destinationTarget;

public bool RotateBackward(Vector3 destinationTarget)

    //stop agent if not within 11.5 degree range
    Vector3 vDirection= (destinationTarget- transform.position).normalized;
    float vResultAngle = Vector2.Angle(new Vector2(transform.forward.x, transform.forward.z), new Vector2(vDirection.x, vDirection.z));
    if (vResultAngle > 11.5f)

    //turn the agent towards the destination direction
    vDirection= destinationTarget- transform.position;
    Quaternion vRotation= Quaternion.LookRotation(vDirection);
    float vTurningSpeed= this.VelocidadDeGiroBase + this.VelocidadDeGiroExtra;
    float vTotalTimeToTurn180= ((0.03f * Mathf.PI) / vTurningSpeed);
    vRotation= Quaternion.Lerp(transform.rotation, vRotation, (180 * Time.deltaTime) / vTotalTimeToTurn180);
    vRotation.x = transform.rotation.x;
    vRotation.z = transform.rotation.z;
    transform.rotation = vRotation;

    //stop agent if not within 11.5 degree range
    vDirection= (destinationTarget- transform.position).normalized;
    vResultAngle = Vector2.Angle(new Vector2(transform.forward.x, transform.forward.z), new Vector2(vDirection.x, vDirection.z));
    bool vResult= vResultAngle <= 11.5f;       
    if (!vResult)
    return vResult;

What it does is that before starting a new route, I ask if its angle with respect to the destination is less or equal 11.5º if it is greater, it stops the agent in his current position and if less or equal he begins to walk but does not give me good results …


This is sort of what the AIPath’s 'slowWhenNotFacingTarget` setting does. It’s implemented with a soft limit, not a hard limit. But the principle is the same.

hello aron, i was eager to get your reply.
The option you mention (SlowWhenNotFacingTarget) is really what I need but I have to have a way to control the stopped time while rotating according to the rotation speed.
I have tried to vary the rotation speed to 999999 but the time to turn and start walking is the same as 630, where can I modify this to work correctly?

Another very important thing that I see is that it is not at all instantaneous when I change my destination route, the agent takes a while to start the new route. I’m going to capture the images of my grid and agent configuration to see what I’m doing wrong

I have a 160X160 terrain with the following configuration:


in optimization I have everything unchecked…



probably before lerp you need set update rotation=false . then rotate it. then set update rotation= true /

try rotate first then check distanse if more then smth can move or set path if less then do nothing

but im not sure that it will help for you or my thoughts is good

hi @Nikita, thanks for the advice I will take it into account when I manage to optimize performance as much as possible so that the routes are calculated as quickly as possible and then I will continue with this step.

@aron_granberg , can you check my settings in the previous post to find out where am I failing? I need to optimize it as much as possible to calculate the instant shape of a route.
My RvoSimulator I have it set like this:

On the other hand, the rvocontroller deactivates them when the agents are stopped.

I also disabled the show graphics option.
What else should I do?

This may be due to the time it takes to calculate the path. It’s hard to say. You can try logging how long the path calculations take using A* Inspector -> Settings -> Path Log Mode.

I think it may be necessary to use a custom movement script (or subclass the existing one) to get exactly the rotation behavior that you want though.