Search Unity

What does desiredVelocity do?

Discussion in 'Navigation' started by Eiseno, Apr 24, 2016.

  1. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    83
    Hi,
    What does desiredVelocity do? What's diffrence between velocity ? And why should i use it ?

    Example Code:
    Code (CSharp):
    1. oid NavAnimationUpdate()
    2.     {
    3.  
    4.         speed = Vector3.Project(agent.desiredVelocity, transform.forward).magnitude;
    5.  
    6.         // angle is the angle between forward and the desired velocity.
    7.         angle = FindAngle(transform.forward, agent.desiredVelocity, transform.up);
    8.  
    9.         // If the angle is within the deadZone
    10.         // set the direction to be along the desired direction and set the angle to be zero.
    11.         if (Mathf.Abs(angle) < deadZone)
    12.         {
    13.             transform.LookAt(transform.position + agent.desiredVelocity);
    14.             angle = 0f;
    15.         }
    16.  
    17.         animSetup.Setup(speed, angle);
    18.     }
    19.  
     
  2. Cynikal

    Cynikal

    Joined:
    Oct 29, 2012
    Posts:
    122
    DesiredMoney = How much money do you want in your bank account?
    Money = How much money you actually have in your bank account.

    Same concept.
    Desired Velocity = "The speed I WANT to go." (Max Speed)
    Velocity = "The speed I am actually going". (Current Speed)
     
    laurentlavigne likes this.
unityunity