Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowAgent : MonoBehaviour {
[SerializeField] ExposeCharacterScene characterScene;
private UnityEngine.AI.NavMeshAgent agent;
private Animator animator;
private static int IDSpeed = Animator.StringToHash("Speed");
void Awake()
agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
animator = GetComponent<Animator>();
IEnumerator Start()
enabled = false;
yield return new WaitWhile( ()=> characterScene.player == null);
enabled = true;
void Update ()
animator.SetFloat(IDSpeed, agent.velocity.magnitude, 0.13f, Time.deltaTime);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment