24 lines
506 B
C#
24 lines
506 B
C#
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
public class MovingController : MonoBehaviour
|
|
{
|
|
public string speedParameterName = "WalkingSpeed";
|
|
|
|
[SerializeField] private NavMeshAgent agent;
|
|
[SerializeField] private Animator animator;
|
|
|
|
void Awake()
|
|
{
|
|
// agent = GetComponent<NavMeshAgent>();
|
|
// animator = GetComponent<Animator>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
float speed = agent.velocity.magnitude;
|
|
|
|
animator.SetFloat(speedParameterName, speed);
|
|
}
|
|
}
|