Created
July 2, 2015 16:58
-
-
Save tsubaki/70590720eedc89c0fc21 to your computer and use it in GitHub Desktop.
Navmeshの移動値でアニメーションを切り替え
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; | |
[RequireComponent(typeof(NavMeshAgent), typeof(Animator))] | |
public class Move : MonoBehaviour | |
{ | |
[SerializeField, HideInInspector] NavMeshAgent agent; | |
[SerializeField, HideInInspector] Animator animator; | |
void Reset() | |
{ | |
agent = GetComponent<NavMeshAgent>(); | |
animator = GetComponent<Animator>(); | |
} | |
void Update () | |
{ | |
animator.SetFloat("Speed", agent.velocity.sqrMagnitude); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment