Files
Gameshit/GOAP/Assets/MovingController.cs
2025-05-31 15:54:23 +02:00

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);
}
}