Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Help Wanted Navmeshagent turn & slope angle parameters for animation controller

Discussion in 'Animation' started by unity_D116971FA1517B8820A0, Jul 28, 2021.

  1. unity_D116971FA1517B8820A0


    Apr 12, 2021
    Hi all,

    My query is regarding how to reference the navmesh agent’s velocity, turn angle, and slope angle to feed the relevant parameters in my animation controller. I managed to correctly reference the agents velocity, but I am still stumped on the turn and slope angle references. The first option to solve may be borrowing and reworking components from the thirdpersoncharacter script. I also browsed through the unity c# documentation, my best guess would be using the variable angularVelocity, or just velocity, may work if referenced to movement in the y+z axis for turning and slope angle (with some further maths) but this is beyond my ability!

    Currently, I have these lines in my AI patrol script as an example (snippet):

    Code (CSharp):
    1. void Update()
    2.         {
    3.             animator.SetFloat("InputMagnitude", agent.velocity.magnitude);  [speed, works]
    4.            // animator.SetFloat("InputAngle", velocity.y); [turn angle, feeds all turning animations]
    5.            // animator.SetFloat("FloorAngle", velocity.z); [slope angle, feeds walking up/down stair animations]
    If anyone has any ideas or solutions on how to solve this, your help would be greatly appreciated.

    Kind regards,