Add project files.

This commit is contained in:
caleb Sandford DeQuincey
2025-10-27 17:05:16 +00:00
parent 93cec4de9e
commit 36f31d54d1
7970 changed files with 2179811 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
namespace RPG.Movement
{
public class Mover : MonoBehaviour
{
[SerializeField] private Transform target;
// Cache components for performance
private NavMeshAgent navMeshAgent;
private Animator animator;
private void Awake()
{
// Get component references once
navMeshAgent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>();
}
void Update()
{
UpdateAnimator();
}
public void MoveTo(Vector3 destination)
{
navMeshAgent.destination = destination;
}
private void UpdateAnimator()
{
// This is your original code, which is correct!
// It just uses the cached variables now.
Vector3 velocity = navMeshAgent.velocity;
Vector3 localVelocity = transform.InverseTransformDirection(velocity);
float speed = localVelocity.z;
animator.SetFloat("forwardSpeed", speed);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 99048001b4ebc1543911415b71049d4a