diff --git a/Assets/PhysicsMaterials/Friction.physicMaterial b/Assets/PhysicsMaterials/Friction.physicMaterial index cb25999..003bf35 100644 --- a/Assets/PhysicsMaterials/Friction.physicMaterial +++ b/Assets/PhysicsMaterials/Friction.physicMaterial @@ -7,7 +7,7 @@ PhysicMaterial: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: Friction - dynamicFriction: 0.01 + dynamicFriction: 0.025315156 staticFriction: 1 bounciness: 0 frictionCombine: 3 diff --git a/Assets/Scenes/Gameplay.unity b/Assets/Scenes/Gameplay.unity index fb2e946..77c5837 100644 --- a/Assets/Scenes/Gameplay.unity +++ b/Assets/Scenes/Gameplay.unity @@ -5350,9 +5350,9 @@ GameObject: - component: {fileID: 2145311071} - component: {fileID: 2145311070} - component: {fileID: 2145311069} - m_Layer: 0 + m_Layer: 7 m_Name: Plane - m_TagString: Untagged + m_TagString: Road m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 diff --git a/Assets/Scripts/VehicleController.cs b/Assets/Scripts/VehicleController.cs index f8438d0..b9c2501 100644 --- a/Assets/Scripts/VehicleController.cs +++ b/Assets/Scripts/VehicleController.cs @@ -131,10 +131,44 @@ public class VehicleController : MonoBehaviour private void ProcessInputs() { - inputVertical = CnInputManager.GetAxis("Vertical"); - inputHorizontal = CnInputManager.GetAxis("Horizontal"); + 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"); + inputHorizontal = CnInputManager.GetAxis("Horizontal"); + } } + private void UpdateVisuals() { counterSteerValue = (Mathf.Abs(velocityLocal.x) > 20f) ? -1f : 1f;