AI controls done

Single-Player
Ali Sharoz 1 month ago
parent b64244f038
commit 16eee417a2

@ -7,7 +7,7 @@ PhysicMaterial:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Friction m_Name: Friction
dynamicFriction: 0.01 dynamicFriction: 0.025315156
staticFriction: 1 staticFriction: 1
bounciness: 0 bounciness: 0
frictionCombine: 3 frictionCombine: 3

@ -5350,9 +5350,9 @@ GameObject:
- component: {fileID: 2145311071} - component: {fileID: 2145311071}
- component: {fileID: 2145311070} - component: {fileID: 2145311070}
- component: {fileID: 2145311069} - component: {fileID: 2145311069}
m_Layer: 0 m_Layer: 7
m_Name: Plane m_Name: Plane
m_TagString: Untagged m_TagString: Road
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0

@ -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()
{ {

Loading…
Cancel
Save