예제 #1
0
    protected void SetupAgentLocomotion()
    {
        if (AgentDone())
        {
            //TODO Resetting path here, otherwise e.g. stepback animation not working properly - CS 03.09.2014
            //Is there a better solution?
            agent.ResetPath();
            locomotion.Do(0, angleDiff);
        }
        else
        {
            float speed = agent.desiredVelocity.magnitude;

            Vector3 velocity = Quaternion.Inverse(transform.rotation) * agent.desiredVelocity;

            float angle = Mathf.Atan2(velocity.x, velocity.z) * 180.0f / 3.14159f;

            locomotion.Do(speed, angle);
        }
    }