game: adding navigation to the car to a tagert position

This commit is contained in:
Sc0rch-thinks 2024-08-05 14:21:00 +08:00
parent a5890e976a
commit 9dfc52a907
5 changed files with 670 additions and 2 deletions

BIN
RunningLateGame/Assets/Prefabs/car.fbx (Stored with Git LFS)

Binary file not shown.

View file

@ -122,7 +122,12 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
<<<<<<< Updated upstream
--- !u!1 &313417770
=======
<<<<<<< Updated upstream
--- !u!1 &330585543
>>>>>>> Stashed changes
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -186,6 +191,7 @@ WheelCollider:
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
<<<<<<< Updated upstream
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
@ -264,6 +270,34 @@ WheelCollider:
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
=======
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_AllowHDROutput: 1
m_UseScreenCoordOverride: 0
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
m_TaaSettings:
m_Quality: 3
m_FrameInfluence: 0.1
m_JitterScale: 1
m_MipBias: 0
m_VarianceClampScale: 0.9
m_ContrastAdaptiveSharpening: 0
=======
>>>>>>> Stashed changes
>>>>>>> Stashed changes
--- !u!1 &410087039
GameObject:
m_ObjectHideFlags: 0
@ -382,6 +416,183 @@ MonoBehaviour:
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 1
--- !u!1 &682128551
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 682128552}
m_Layer: 0
m_Name: wheels (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &682128552
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 682128551}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 946837642}
- {fileID: 795338596}
- {fileID: 1780227556}
- {fileID: 712463376}
m_Father: {fileID: 175694171717526785}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &712463375
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 712463376}
- component: {fileID: 712463377}
m_Layer: 0
m_Name: front_r
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &712463376
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 712463375}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.7592659, y: -0.23072661, z: -0.9910543}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 682128552}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!146 &712463377
WheelCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 712463375}
serializedVersion: 2
m_Center: {x: -0.06, y: 0.15, z: 0}
m_Radius: 0.32
m_SuspensionSpring:
spring: 3500
damper: 450
targetPosition: 0.5
m_SuspensionDistance: 0.3
m_ForceAppPointDistance: 0
m_Mass: 20
m_WheelDampingRate: 0.25
m_ForwardFriction:
m_ExtremumSlip: 0.4
m_ExtremumValue: 1
m_AsymptoteSlip: 0.8
m_AsymptoteValue: 0.5
m_Stiffness: 1
m_SidewaysFriction:
m_ExtremumSlip: 0.2
m_ExtremumValue: 1
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
--- !u!1 &795338595
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 795338596}
- component: {fileID: 795338597}
m_Layer: 0
m_Name: back_r
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &795338596
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 795338595}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.7592659, y: -0.23072661, z: 0.9910559}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 682128552}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!146 &795338597
WheelCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 795338595}
serializedVersion: 2
m_Center: {x: -0.06, y: 0.15, z: 0}
m_Radius: 0.32
m_SuspensionSpring:
spring: 3500
damper: 450
targetPosition: 0.5
m_SuspensionDistance: 0.3
m_ForceAppPointDistance: 0
m_Mass: 20
m_WheelDampingRate: 0.25
m_ForwardFriction:
m_ExtremumSlip: 0.4
m_ExtremumValue: 1
m_AsymptoteSlip: 0.8
m_AsymptoteValue: 0.5
m_Stiffness: 1
m_SidewaysFriction:
m_ExtremumSlip: 0.2
m_ExtremumValue: 1
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
--- !u!1 &832575517
GameObject:
m_ObjectHideFlags: 0
@ -431,7 +642,13 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
<<<<<<< Updated upstream
--- !u!1 &1024498420
=======
<<<<<<< Updated upstream
=======
--- !u!1 &946837641
>>>>>>> Stashed changes
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -439,20 +656,32 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
<<<<<<< Updated upstream
- component: {fileID: 1024498421}
m_Layer: 0
m_Name: wheels (1)
=======
- component: {fileID: 946837642}
- component: {fileID: 946837643}
m_Layer: 0
m_Name: back_l
>>>>>>> Stashed changes
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
<<<<<<< Updated upstream
--- !u!4 &1024498421
=======
--- !u!4 &946837642
>>>>>>> Stashed changes
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
<<<<<<< Updated upstream
m_GameObject: {fileID: 1024498420}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
@ -497,6 +726,57 @@ Transform:
m_Children: []
m_Father: {fileID: 175694171717526785}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
=======
m_GameObject: {fileID: 946837641}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.7592659, y: -0.23072661, z: 0.9910559}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 682128552}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!146 &946837643
WheelCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 946837641}
serializedVersion: 2
m_Center: {x: 0.06, y: 0.15, z: 0}
m_Radius: 0.32
m_SuspensionSpring:
spring: 3500
damper: 450
targetPosition: 0.5
m_SuspensionDistance: 0.3
m_ForceAppPointDistance: 0
m_Mass: 20
m_WheelDampingRate: 0.25
m_ForwardFriction:
m_ExtremumSlip: 0.4
m_ExtremumValue: 1
m_AsymptoteSlip: 0.8
m_AsymptoteValue: 0.5
m_Stiffness: 1
m_SidewaysFriction:
m_ExtremumSlip: 0.2
m_ExtremumValue: 1
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
>>>>>>> Stashed changes
>>>>>>> Stashed changes
--- !u!1 &1234375544
GameObject:
m_ObjectHideFlags: 0
@ -590,7 +870,13 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
<<<<<<< Updated upstream
--- !u!1 &1549667941
=======
<<<<<<< Updated upstream
=======
--- !u!1 &1527981079
>>>>>>> Stashed changes
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -598,21 +884,32 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
<<<<<<< Updated upstream
- component: {fileID: 1549667942}
- component: {fileID: 1549667943}
m_Layer: 0
m_Name: back_l
=======
- component: {fileID: 1527981080}
m_Layer: 0
m_Name: Target
>>>>>>> Stashed changes
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
<<<<<<< Updated upstream
--- !u!4 &1549667942
=======
--- !u!4 &1527981080
>>>>>>> Stashed changes
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
<<<<<<< Updated upstream
m_GameObject: {fileID: 1549667941}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0.7071068, w: 0.7071068}
@ -732,6 +1029,17 @@ WheelCollider:
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
=======
m_GameObject: {fileID: 1527981079}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 543450651658663480}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
>>>>>>> Stashed changes
--- !u!1001 &1703341036
PrefabInstance:
m_ObjectHideFlags: 0
@ -747,6 +1055,14 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3313027092289172340, guid: aebcdae242e01f94b8df85895a81a0ff,
type: 3}
<<<<<<< Updated upstream
=======
propertyPath: entityType
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3313027092289172340, guid: aebcdae242e01f94b8df85895a81a0ff,
type: 3}
>>>>>>> Stashed changes
propertyPath: movingRange
value: 100
objectReference: {fileID: 0}
@ -800,11 +1116,93 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
<<<<<<< Updated upstream
=======
- target: {fileID: 8179579322411983252, guid: aebcdae242e01f94b8df85895a81a0ff,
type: 3}
propertyPath: m_ApplyRootMotion
value: 0
objectReference: {fileID: 0}
>>>>>>> Stashed changes
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: aebcdae242e01f94b8df85895a81a0ff, type: 3}
<<<<<<< Updated upstream
=======
--- !u!1 &1780227555
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1780227556}
- component: {fileID: 1780227557}
m_Layer: 0
m_Name: front_l
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1780227556
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1780227555}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.7592659, y: -0.23072661, z: -0.9910543}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 682128552}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!146 &1780227557
WheelCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1780227555}
serializedVersion: 2
m_Center: {x: 0.06, y: 0.15, z: 0}
m_Radius: 0.32
m_SuspensionSpring:
spring: 3500
damper: 450
targetPosition: 0.5
m_SuspensionDistance: 0.3
m_ForceAppPointDistance: 0
m_Mass: 20
m_WheelDampingRate: 0.25
m_ForwardFriction:
m_ExtremumSlip: 0.4
m_ExtremumValue: 1
m_AsymptoteSlip: 0.8
m_AsymptoteValue: 0.5
m_Stiffness: 1
m_SidewaysFriction:
m_ExtremumSlip: 0.2
m_ExtremumValue: 1
m_AsymptoteSlip: 0.5
m_AsymptoteValue: 0.75
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
>>>>>>> Stashed changes
--- !u!1 &2031846085
GameObject:
m_ObjectHideFlags: 0
@ -878,12 +1276,20 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
<<<<<<< Updated upstream
m_LocalScale: {x: 151.85318, y: 76.588165, z: 323.46393}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4361362965383754916}
- {fileID: 1024498421}
- {fileID: 1125800493}
=======
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4361362965383754916}
- {fileID: 682128552}
>>>>>>> Stashed changes
m_Father: {fileID: 543450651658663480}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &543450651658663480
@ -899,6 +1305,10 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
<<<<<<< Updated upstream
=======
- {fileID: 1527981080}
>>>>>>> Stashed changes
- {fileID: 175694171717526785}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -932,6 +1342,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6da9430305b32f446a2517f4a73fdf57, type: 3}
m_Name:
m_EditorClassIdentifier:
<<<<<<< Updated upstream
acceleration: 30
turnAngle: 30
wheels:
@ -948,6 +1359,24 @@ MonoBehaviour:
wheelCollider: {fileID: 1574385376}
axel: 1
brakeForce: 100
=======
acceleration: 60
turnAngle: 45
wheels:
- wheelModel: {fileID: 7018000553910114355}
wheelCollider: {fileID: 1780227557}
axel: 0
- wheelModel: {fileID: 3543920631802817220}
wheelCollider: {fileID: 712463377}
axel: 0
- wheelModel: {fileID: 1041543500241701263}
wheelCollider: {fileID: 946837643}
axel: 1
- wheelModel: {fileID: 1582988942254250249}
wheelCollider: {fileID: 795338597}
axel: 1
brakeForce: 1000
>>>>>>> Stashed changes
braking: 0
--- !u!114 &919132148007562372
MonoBehaviour:
@ -961,6 +1390,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bc82a40176164f02897928bd573bc2ca, type: 3}
m_Name:
m_EditorClassIdentifier:
<<<<<<< Updated upstream
=======
carPosition: {fileID: 175694171717526785}
stoppingDistance: 7
slowingSpeed: 5
slowingDistance: 30
>>>>>>> Stashed changes
--- !u!1 &1041543500241701263
GameObject:
m_ObjectHideFlags: 0
@ -1005,9 +1441,15 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7018000553910114355}
serializedVersion: 2
<<<<<<< Updated upstream
m_LocalRotation: {x: 0, y: -0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0.7592659, y: -0.23072661, z: -0.9910543}
m_LocalScale: {x: 30.643345, y: 6.1144395, z: 30.643345}
=======
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.7592659, y: -0.23072661, z: -0.9910543}
m_LocalScale: {x: 1, y: 1, z: 1}
>>>>>>> Stashed changes
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -1054,9 +1496,15 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1041543500241701263}
serializedVersion: 2
<<<<<<< Updated upstream
m_LocalRotation: {x: 0, y: -0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0.7592659, y: -0.23072661, z: 0.9910559}
m_LocalScale: {x: 30.643345, y: 6.1144395, z: 30.643345}
=======
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.7592659, y: -0.23072661, z: 0.9910559}
m_LocalScale: {x: 1, y: 1, z: 1}
>>>>>>> Stashed changes
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -1071,7 +1519,11 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
<<<<<<< Updated upstream
m_LocalScale: {x: 0.0065853084, y: 0.013056847, z: 0.003091535}
=======
m_LocalScale: {x: 1, y: 1, z: 1}
>>>>>>> Stashed changes
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4102084789518556337}
@ -1196,9 +1648,15 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1582988942254250249}
serializedVersion: 2
<<<<<<< Updated upstream
m_LocalRotation: {x: 0, y: -0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: -0.7592659, y: -0.23072661, z: 0.9910559}
m_LocalScale: {x: 30.643345, y: 6.1144395, z: 30.643345}
=======
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.7592659, y: -0.23072661, z: 0.9910559}
m_LocalScale: {x: 1, y: 1, z: 1}
>>>>>>> Stashed changes
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -1914,8 +2372,13 @@ BoxCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
<<<<<<< Updated upstream
m_Size: {x: 0.01, y: 0.014814308, z: 0.010120844}
m_Center: {x: 0, y: 0.004394592, z: 0.00006042119}
=======
m_Size: {x: 1.5185318, y: 1.1346006, z: 3.2737274}
m_Center: {x: 0, y: 0.33657372, z: -0.019544065}
>>>>>>> Stashed changes
--- !u!4 &8417055251110083872
Transform:
m_ObjectHideFlags: 0
@ -1924,9 +2387,15 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3543920631802817220}
serializedVersion: 2
<<<<<<< Updated upstream
m_LocalRotation: {x: 0, y: -0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: -0.7592659, y: -0.23072661, z: -0.9910543}
m_LocalScale: {x: 30.643345, y: 6.1144395, z: 30.643345}
=======
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.7592659, y: -0.23072661, z: -0.9910543}
m_LocalScale: {x: 1, y: 1, z: 1}
>>>>>>> Stashed changes
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -2015,6 +2484,10 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
>>>>>>> Stashed changes
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0

View file

@ -1,7 +1,11 @@
/*
* author: lin hengrui ryan
* date: 30/7/2024
<<<<<<< Updated upstream
* description: ai code for the different ai in the game
=======
* description: AI code for the different AI in the game
>>>>>>> Stashed changes
*/
using System.Collections;
@ -11,6 +15,7 @@
public class AI : MonoBehaviour
{
<<<<<<< Updated upstream
/// <summary>
/// the types of ai that this game object can be
/// </summary>
@ -29,6 +34,17 @@ public enum EntityType
/// to show the entity types in the inspector as a dropdown
/// </summary>
public EntityType entityType;
=======
/// <summary>
/// to save resources when referring to the speed of this AI
/// </summary>
private static readonly int AnimatorSpeed = Animator.StringToHash("Speed");
>>>>>>> Stashed changes
/// <summary>
/// set the layers the AI can be on
@ -70,35 +86,63 @@ public enum EntityType
/// </summary>
private string _nextState;
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
/// <summary>
/// to set initial values
/// </summary>
public void Awake()
{
<<<<<<< Updated upstream
_agent = GetComponent<NavMeshAgent>();
if (entityType == EntityType.Human)
{
_animator = GetComponent<Animator>();
_currentState = "Strolling";
}
=======
_agent = GetComponent<NavMeshAgent>();
_animator = GetComponent<Animator>();
_currentState = "Strolling";
>>>>>>> Stashed changes
_nextState = _currentState;
ChangeState();
}
/// <summary>
<<<<<<< Updated upstream
/// to update the speed of the AI to the animator each frame and to update any state changes to the ai
/// </summary>
public void Update()
{
if (entityType == EntityType.Human) _animator.SetFloat(AnimatorSpeed, _agent.velocity.magnitude);
=======
/// to update the speed of the AI to the animator each frame and to update any state changes to the AI
/// </summary>
public void Update()
{
_animator.SetFloat(AnimatorSpeed, _agent.velocity.magnitude);
>>>>>>> Stashed changes
_currentState = _nextState;
}
/// <summary>
/// to change the scene when needed
/// </summary>
<<<<<<< Updated upstream
public void ChangeState()
=======
private void ChangeState()
>>>>>>> Stashed changes
{
StartCoroutine(_currentState);
}
@ -128,7 +172,10 @@ private IEnumerator Strolling()
while (_currentState == "Strolling")
{
<<<<<<< Updated upstream
Debug.Log("strolling");
=======
>>>>>>> Stashed changes
if (!_destinationPointSet)
SearchWalkPoint();
else
@ -141,4 +188,9 @@ private IEnumerator Strolling()
ChangeState();
}
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
}

View file

@ -13,12 +13,17 @@ public enum Axel
public float acceleration;
public float turnAngle;
public List<Wheel> wheels;
<<<<<<< Updated upstream
public float brakeForce = 50.0f;
=======
public float brakeForce;
>>>>>>> Stashed changes
private float _currentAcceleration;
private float _currentTurn;
public bool braking;
<<<<<<< Updated upstream
private void FixedUpdate()
{
@ -32,6 +37,21 @@ public void SetInputs(float forwardAmount,float turnAmount)
_currentAcceleration = forwardAmount*acceleration;
_currentTurn = turnAmount*turnAngle;
}
=======
private void FixedUpdate()
{
Brake();
Move();
Steering();
}
public void SetInputs(float forwardAmount, float turnAmount)
{
_currentAcceleration = forwardAmount * acceleration;
_currentTurn = turnAmount * turnAngle;
}
>>>>>>> Stashed changes
public void Move()
{
foreach (var wheel in wheels) wheel.wheelCollider.motorTorque = _currentAcceleration;
@ -61,4 +81,9 @@ public struct Wheel
public WheelCollider wheelCollider;
public Axel axel;
}
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
}

View file

@ -1,19 +1,137 @@
<<<<<<< Updated upstream
using System;
=======
using System.Collections;
>>>>>>> Stashed changes
using UnityEngine;
public class AICar : MonoBehaviour
{
<<<<<<< Updated upstream
private CarController _carController;
private void Awake()
{
_carController = GetComponent<CarController>();
=======
[SerializeField] private Transform carPosition;
[SerializeField] private float stoppingDistance;
[SerializeField] private float slowingSpeed;
[SerializeField] private float slowingDistance;
[SerializeField] private float reverseDist;
private CarController _car;
private string _currentState;
private Transform _driveTarget;
private string _nextState;
private void Awake()
{
var hasChild = false;
var i = 0;
GameObject test;
while (!hasChild)
{
test = gameObject.transform.GetChild(i).gameObject;
if (test.name == "Target")
{
_driveTarget = test.transform;
hasChild = true;
}
else
{
i++;
}
}
_car = GetComponent<CarController>();
_currentState = "Driving";
_nextState = _currentState;
ChangeState();
>>>>>>> Stashed changes
}
private void Update()
{
<<<<<<< Updated upstream
float forwardAmount = 1f;
float turnAmount = 1f;
_carController.SetInputs(forwardAmount,turnAmount);
=======
_currentState = _nextState;
}
private void ChangeState()
{
StartCoroutine(_currentState);
}
private IEnumerator Driving()
{
_car = GetComponent<CarController>();
while (_currentState == "Driving")
{
var accelerationAmount = 0f;
var turnAmount = 0f;
var targetPosition = _driveTarget.position;
var dirToMove = (targetPosition - carPosition.transform.position).normalized;
var forwardsAmount = Vector3.Dot(carPosition.transform.forward, dirToMove);
var directionToDrive = Vector3.SignedAngle(carPosition.transform.forward, dirToMove, Vector3.up);
var distanceToTarget = Vector3.Distance(carPosition.position, targetPosition);
if (distanceToTarget >= stoppingDistance)
{
_car.braking = false;
//in front of target position
if (forwardsAmount > 0)
{
//closer than the slowing distance
if (distanceToTarget <= slowingDistance)
{
//the car is very fast
if (carPosition.GetComponent<Rigidbody>().velocity.magnitude > slowingSpeed)
accelerationAmount = -2;
else
accelerationAmount = 1;
}
else
{
accelerationAmount = 1;
}
}
else
{
if (distanceToTarget < reverseDist)
{
accelerationAmount = -1;
}
else
{
accelerationAmount = 1;
}
}
if (directionToDrive < 0)
turnAmount = 1;
else if (directionToDrive > 0)
turnAmount = -1;
else
turnAmount = 0;
}
else
{
_car.braking = true;
accelerationAmount = 0f;
turnAmount = 0f;
}
Debug.Log(carPosition.GetComponent<Rigidbody>().velocity.magnitude);
_car.SetInputs(accelerationAmount, turnAmount);
yield return new WaitForEndOfFrame();
}
>>>>>>> Stashed changes
}
}