Created
April 23, 2017 07:08
-
-
Save tarukosu/9145fdb5429d0a5f767af0d0f033af84 to your computer and use it in GitHub Desktop.
unitychanAnimation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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