I was following the tutorial again after fixing my previous errors, but now I must have broke something because my character can’t move. I didn’t change anything from any of the previous lessons…?
using System.Collections;
using System.Collections.Generic;
using RPG.Combat;
using RPG.Core;
using UnityEngine;
using UnityEngine.AI;
namespace RPG.Movement
{
public class Mover : MonoBehaviour, IAction
{
[SerializeField] Transform target;
NavMeshAgent navMeshAgent;
private void Start()
{
navMeshAgent = GetComponent<NavMeshAgent>();
}
void Update()
{
UpdateAnimator();
}
public void StartMoveAction(Vector3 destination)
{
GetComponent<ActionScheduler>().StartAction(this);
GetComponent<Fighter>().Cancel();
MoveTo(destination);
}
public void MoveTo(Vector3 destination)
{
navMeshAgent.destination = destination;
navMeshAgent.isStopped = false;
}
public void Cancel()
{
navMeshAgent.isStopped = true;
}
private void UpdateAnimator()
{
Vector3 velocity = navMeshAgent.velocity;
Vector3 localVelocity = transform.InverseTransformDirection(velocity);
float speed = localVelocity.z;
GetComponent<Animator>().SetFloat("forwardSpeed", speed);
}
}
}