Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created July 2, 2015 16:58
Show Gist options
  • Save tsubaki/70590720eedc89c0fc21 to your computer and use it in GitHub Desktop.
Save tsubaki/70590720eedc89c0fc21 to your computer and use it in GitHub Desktop.
Navmeshの移動値でアニメーションを切り替え
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