Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created Jul 2, 2015
Embed
What would you like to do?
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