Skip to content

Instantly share code, notes, and snippets.

@tarukosu
Created April 23, 2017 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarukosu/9145fdb5429d0a5f767af0d0f033af84 to your computer and use it in GitHub Desktop.
Save tarukosu/9145fdb5429d0a5f767af0d0f033af84 to your computer and use it in GitHub Desktop.
unitychanAnimation.cs
using UnityEngine;
using UnityEngine.AI;
public class unitychanAnimation : MonoBehaviour {
NavMeshAgent agent;
Animator animator;
void Start () {
agent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>();
}
void Update () {
var speed = agent.velocity.magnitude / transform.localScale.y;
animator.SetFloat("Speed", speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment