Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Animator), typeof(NavMeshAgent))]
public class MoveNavigationWithAnimator : MonoBehaviour {
[SerializeField, HideInInspector] Animator animator;
[SerializeField, HideInInspector] NavMeshAgent agent;
[SerializeField] Transform target;
private static int paramIsStop = Animator.StringToHash ("IsStop");
void Reset()
animator = GetComponent<Animator> ();
agent = GetComponent<NavMeshAgent> ();
void Start ()
agent.SetDestination (target.position);
agent.updatePosition = false;
void Update()
animator.SetBool (paramIsStop, agent.remainingDistance < agent.stoppingDistance);
agent.nextPosition = transform.position;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment