From 5d88ed4faf3c08e1645eff6f7d69f0ef8305916a Mon Sep 17 00:00:00 2001 From: Ciakon Date: Fri, 5 Apr 2024 12:31:05 +0200 Subject: [PATCH] crazy braking --- Assets/Scenes/AI Training.unity | 410 +------------------------------ Assets/Scripts/car control v2.cs | 10 +- 2 files changed, 8 insertions(+), 412 deletions(-) diff --git a/Assets/Scenes/AI Training.unity b/Assets/Scenes/AI Training.unity index 0fe7ad3..2f3909e 100644 --- a/Assets/Scenes/AI Training.unity +++ b/Assets/Scenes/AI Training.unity @@ -185,53 +185,6 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 450060be716600a46927ba00fb04135b, type: 3} ---- !u!1 &218143925 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 4258781391370674817, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - m_PrefabInstance: {fileID: 2124232202} - m_PrefabAsset: {fileID: 0} ---- !u!4 &218143928 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - m_PrefabInstance: {fileID: 2124232202} - m_PrefabAsset: {fileID: 0} ---- !u!114 &218143929 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 218143925} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a23c7d66d3ff94847a946cf7b30ca1b7, type: 3} - m_Name: - m_EditorClassIdentifier: - motorTorque: 2000 - maxSpeed: 20 - steeringRange: 30 ---- !u!64 &218143930 -MeshCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 218143925} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_IsTrigger: 0 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 5 - m_Convex: 1 - m_CookingOptions: 30 - m_Mesh: {fileID: 0} --- !u!4 &257377415 stripped Transform: m_CorrespondingSourceObject: {fileID: 2129857982551333138, guid: 450060be716600a46927ba00fb04135b, type: 3} @@ -752,7 +705,7 @@ MonoBehaviour: maxSpeed: 1000 steeringRange: 60 steeringRangeAtMaxSpeed: 35 - autoBrake: 5000 + autoBrake: 3000 --- !u!1001 &760601908 PrefabInstance: m_ObjectHideFlags: 0 @@ -1063,7 +1016,6 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1802081976} - - {fileID: 218143928} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1047804915 @@ -1535,366 +1487,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 2129857982551333138, guid: 450060be716600a46927ba00fb04135b, type: 3} m_PrefabInstance: {fileID: 330340151} m_PrefabAsset: {fileID: 0} ---- !u!1001 &2124232202 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 977927543} - m_Modifications: - - target: {fileID: 239808068493503110, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Drag - value: 0.1 - objectReference: {fileID: 0} - - target: {fileID: 239808068493503110, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Mass - value: 1500 - objectReference: {fileID: 0} - - target: {fileID: 599143912545070145, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.y - value: 0.4 - objectReference: {fileID: 0} - - target: {fileID: 613652968110647363, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 613652968110647363, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1082829397675514308, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: motorized - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Mass - value: 50 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Radius - value: 0.004 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_WheelDampingRate - value: 0.25 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionDistance - value: 0.001 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.damper - value: 5000 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.spring - value: 500 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_Stiffness - value: 0.9 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_Stiffness - value: 0.95 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumSlip - value: 0.2 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteSlip - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumValue - value: 0.8 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_ExtremumSlip - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteValue - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteSlip - value: 0.6 - objectReference: {fileID: 0} - - target: {fileID: 1993614641690278306, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteValue - value: 7.5 - objectReference: {fileID: 0} - - target: {fileID: 2390583446416444971, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.y - value: 0.4 - objectReference: {fileID: 0} - - target: {fileID: 2599178774178468494, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: motorized - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3790546188144705370, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: motorized - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4083241972678019647, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: motorized - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4258781391370674817, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Name - value: Ford - objectReference: {fileID: 0} - - target: {fileID: 4562493253198073265, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: centreOfGravityOffset - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.x - value: 15 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.y - value: 0.7 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.z - value: 70 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalRotation.w - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalRotation.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 180 - objectReference: {fileID: 0} - - target: {fileID: 5049018613629602103, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6013378969511991378, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.y - value: 0.4 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Mass - value: 50 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Radius - value: 0.004 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_WheelDampingRate - value: 0.25 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionDistance - value: 0.001 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.damper - value: 5000 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.spring - value: 500 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_Stiffness - value: 0.9 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_Stiffness - value: 0.95 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumSlip - value: 0.2 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteSlip - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumValue - value: 0.8 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_ExtremumSlip - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteValue - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteSlip - value: 0.6 - objectReference: {fileID: 0} - - target: {fileID: 6373920133476611951, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteValue - value: 7.5 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Mass - value: 50 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Radius - value: 0.004 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_WheelDampingRate - value: 0.25 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionDistance - value: 0.001 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.damper - value: 5000 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.spring - value: 500 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_Stiffness - value: 0.9 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_Stiffness - value: 0.95 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumSlip - value: 0.2 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteSlip - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumValue - value: 0.8 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_ExtremumSlip - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteValue - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteSlip - value: 0.6 - objectReference: {fileID: 0} - - target: {fileID: 6950856957915183442, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteValue - value: 7.5 - objectReference: {fileID: 0} - - target: {fileID: 7320587279522380063, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_LocalPosition.y - value: 0.4 - objectReference: {fileID: 0} - - target: {fileID: 7565772832575379995, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Enabled - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Mass - value: 50 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_Radius - value: 0.004 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_WheelDampingRate - value: 0.25 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionDistance - value: 0.001 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.damper - value: 5000 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SuspensionSpring.spring - value: 500 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_Stiffness - value: 0.9 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_Stiffness - value: 0.95 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumSlip - value: 0.2 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteSlip - value: 0.3 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_ExtremumValue - value: 0.8 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_ExtremumSlip - value: 0.01 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_ForwardFriction.m_AsymptoteValue - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteSlip - value: 0.6 - objectReference: {fileID: 0} - - target: {fileID: 8180478512642462433, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - propertyPath: m_SidewaysFriction.m_AsymptoteValue - value: 7.5 - objectReference: {fileID: 0} - m_RemovedComponents: - - {fileID: 4562493253198073265, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 4258781391370674817, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - insertIndex: -1 - addedObject: {fileID: 218143929} - - targetCorrespondingSourceObject: {fileID: 4258781391370674817, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} - insertIndex: -1 - addedObject: {fileID: 218143930} - m_SourcePrefab: {fileID: 100100000, guid: 77e4cd38c4994de4f9312bea83b75104, type: 3} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/car control v2.cs b/Assets/Scripts/car control v2.cs index 6ace9dc..7f2ae93 100644 --- a/Assets/Scripts/car control v2.cs +++ b/Assets/Scripts/car control v2.cs @@ -54,9 +54,7 @@ public class carcontrolv2 : MonoBehaviour bool isStopping = vInput == 0; // range - bool isBraking = vInput < 0 && forwardSpeed > 0; - - Debug.Log(vInput); + bool isBraking = (vInput < 0 && forwardSpeed > 0) || (vInput > 0 && forwardSpeed < 0); foreach (var wheel in wheels) { @@ -87,6 +85,12 @@ public class carcontrolv2 : MonoBehaviour // If the user is trying to go in the opposite direction // apply brakes to all wheels wheel.WheelCollider.brakeTorque = Mathf.Abs(vInput) * brakeTorque + autoBrake; + + if (forwardSpeed < 0) + { + wheel.WheelCollider.brakeTorque = (Mathf.Abs(vInput) * brakeTorque + autoBrake) * 5; + } + // wheel.WheelCollider.motorTorque = 0; } }