Search Unity

Question Navmeshagent turn & slope angle parameters for animation controller

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

  1. unity_D116971FA1517B8820A0

    unity_D116971FA1517B8820A0

    Joined:
    Apr 12, 2021
    Posts:
    6
    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,

    Alex
     
  2. TaintedJester

    TaintedJester

    Joined:
    Jun 15, 2019
    Posts:
    4
    Did you ever find an answer to this? Im currently stuck trying to figure it out.
     
  3. unity_D116971FA1517B8820A0

    unity_D116971FA1517B8820A0

    Joined:
    Apr 12, 2021
    Posts:
    6
    Hey there!

    I never found an answer to this - I’m now working with a developer though admittedly she is a Unity c# specialist and not animation, we could not find a solution. You can reference the turn angle using one command but it only plays the animation for a split second and not the entire length of the corner.

    I did get a lead after posting this using something like vector3 as part of the script, but I genuinely have no idea how it works. Hence why I am here. :)

    Please let me know if you have any success! All the best.