Initial commit

This commit is contained in:
2026-02-10 21:27:46 +00:00
commit 3a8163af21
3261 changed files with 563042 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using UnityEngine;
using UnityEngine.AI;
[RequireComponent(typeof(NavMeshAgent))]
public class SimplePlayerController : MonoBehaviour
{
public float rotationSpeed = 10f;
public float stopDistanceTolerance = 0.1f;
NavMeshAgent agent;
Vector3 lastVelocity;
void Awake()
{
agent = GetComponent<NavMeshAgent>();
agent.updateRotation = false; // manual rotation
}
void Update()
{
Vector3 vel = agent.velocity;
if (vel.sqrMagnitude > 0.01f)
{
Quaternion targetRot = Quaternion.LookRotation(vel.normalized);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, rotationSpeed * Time.deltaTime);
}
if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + stopDistanceTolerance)
{
agent.isStopped = true;
}
else
{
agent.isStopped = false;
}
lastVelocity = vel;
}
public Vector3 GetVelocity() => lastVelocity;
}