Search Unity

Mechanim and NavMesh Movements

Discussion in 'Scripting' started by SimplyZak, Sep 4, 2015.

  1. SimplyZak

    SimplyZak

    Joined:
    Sep 2, 2015
    Posts:
    3
    Hey Everyone,

    After spending a lot of time on google and youtube looking for a guide on how to convert NavMesh movements into mechanim animation, and finding nothing. I started looking for a way to convert NavMesh movements into normal animations. I found something and so I converted the system found for NavMesh into legacy animations into a NavMesh into Mechanim Animation. It was actually incredibly simple. Check it out and use it however you want.

    Code (CSharp):
    1. anim.SetFloat ("speed", playerAgent.velocity.magnitude);
    Basically what you have is the playerAgent, which is the NavMeshAgent that controls my player character, needs to send its current speed to the Animator, anim. How we do this is with playerAgent.velocity.magnitude; now velocity is speed and direction, but the magnitude is just the speed variable from the velocity. Hope this helped.

    Thanks,
    SimplyZak