|
|
@ -130,10 +130,44 @@ public class VehicleController : MonoBehaviour
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ProcessInputs()
|
|
|
|
private void ProcessInputs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isAIControlled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// --- Get AI-relevant steering info ---
|
|
|
|
|
|
|
|
Vector3 targetPoint = targetTracker.TargetPos;
|
|
|
|
|
|
|
|
targetPoint.y = transform.position.y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 directionToTarget = (targetPoint - transform.position).normalized;
|
|
|
|
|
|
|
|
float angleToTarget = Vector3.Angle(transform.forward, directionToTarget);
|
|
|
|
|
|
|
|
float distanceToTarget = Vector3.Distance(transform.position, targetPoint);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --- Dynamic throttle logic ---
|
|
|
|
|
|
|
|
if (distanceToTarget < targetStoppingDistance)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inputVertical = 0f; // Stop when close enough
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (angleToTarget > 60f)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inputVertical = 0.3f; // Slow down for sharp turns
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (angleToTarget > 30f)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inputVertical = 0.6f; // Moderate turn
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inputVertical = 0.95f; // Full throttle
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputHorizontal = 0f; // Let AI use steeringAI instead
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inputVertical = CnInputManager.GetAxis("Vertical");
|
|
|
|
inputVertical = CnInputManager.GetAxis("Vertical");
|
|
|
|
inputHorizontal = CnInputManager.GetAxis("Horizontal");
|
|
|
|
inputHorizontal = CnInputManager.GetAxis("Horizontal");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateVisuals()
|
|
|
|
private void UpdateVisuals()
|
|
|
|
{
|
|
|
|
{
|
|
|
|