Compare commits

...

5 commits

Author SHA1 Message Date
Sc0rch-thinks 5e603a1e17 Merge branch 'AI'
# Conflicts:
#	RunningLateGame/Assets/Prefabs/car.fbx
#	RunningLateGame/Assets/Scenes/SampleScene.unity
#	RunningLateGame/Assets/Scripts/AI.cs
#	RunningLateGame/Assets/Scripts/CarController.cs
#	RunningLateGame/Assets/Scripts/ai car.cs
2024-08-05 14:29:25 +08:00
Sc0rch-thinks 9dfc52a907 game: adding navigation to the car to a tagert position 2024-08-05 14:21:00 +08:00
Sc0rch-thinks a5890e976a game: adding the car manger Scripts 2024-08-02 12:23:06 +08:00
Sc0rch-thinks 6f6db679fc game: refactor and commenting the ai plus some testing 2024-07-30 15:52:06 +08:00
Sc0rch-thinks 2a0ed5cd67 game: first iteration of passive ai 2024-07-30 14:06:00 +08:00
4 changed files with 846 additions and 0 deletions

View file

@ -122,7 +122,16 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
<<<<<<< HEAD
--- !u!1 &313417770
=======
<<<<<<< Updated upstream
--- !u!1 &313417770
=======
<<<<<<< Updated upstream
--- !u!1 &330585543
>>>>>>> Stashed changes
>>>>>>> AI
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -186,6 +195,10 @@ WheelCollider:
m_Stiffness: 1
m_IncludeLayers:
serializedVersion: 2
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
@ -264,6 +277,37 @@ WheelCollider:
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
<<<<<<< HEAD
=======
=======
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
>>>>>>> AI
--- !u!1 &410087039
GameObject:
m_ObjectHideFlags: 0
@ -382,6 +426,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 +652,17 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
<<<<<<< HEAD
--- !u!1 &1024498420
=======
<<<<<<< Updated upstream
--- !u!1 &1024498420
=======
<<<<<<< Updated upstream
=======
--- !u!1 &946837641
>>>>>>> Stashed changes
>>>>>>> AI
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -439,20 +670,45 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
<<<<<<< HEAD
- component: {fileID: 1024498421}
m_Layer: 0
m_Name: wheels (1)
=======
<<<<<<< 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
>>>>>>> AI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
<<<<<<< HEAD
--- !u!4 &1024498421
=======
<<<<<<< Updated upstream
--- !u!4 &1024498421
=======
--- !u!4 &946837642
>>>>>>> Stashed changes
>>>>>>> AI
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
m_GameObject: {fileID: 1024498420}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
@ -497,6 +753,60 @@ Transform:
m_Children: []
m_Father: {fileID: 175694171717526785}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
<<<<<<< HEAD
=======
=======
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
>>>>>>> AI
--- !u!1 &1234375544
GameObject:
m_ObjectHideFlags: 0
@ -590,7 +900,17 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
<<<<<<< HEAD
--- !u!1 &1549667941
=======
<<<<<<< Updated upstream
--- !u!1 &1549667941
=======
<<<<<<< Updated upstream
=======
--- !u!1 &1527981079
>>>>>>> Stashed changes
>>>>>>> AI
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -598,21 +918,45 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
- component: {fileID: 1549667942}
- component: {fileID: 1549667943}
m_Layer: 0
m_Name: back_l
<<<<<<< HEAD
=======
=======
- component: {fileID: 1527981080}
m_Layer: 0
m_Name: Target
>>>>>>> Stashed changes
>>>>>>> AI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
<<<<<<< HEAD
--- !u!4 &1549667942
=======
<<<<<<< Updated upstream
--- !u!4 &1549667942
=======
--- !u!4 &1527981080
>>>>>>> Stashed changes
>>>>>>> AI
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
m_GameObject: {fileID: 1549667941}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0.7071068, w: 0.7071068}
@ -732,6 +1076,20 @@ WheelCollider:
m_LayerOverridePriority: 0
m_Enabled: 1
m_ProvidesContacts: 0
<<<<<<< HEAD
=======
=======
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
>>>>>>> AI
--- !u!1001 &1703341036
PrefabInstance:
m_ObjectHideFlags: 0
@ -747,6 +1105,17 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3313027092289172340, guid: aebcdae242e01f94b8df85895a81a0ff,
type: 3}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
propertyPath: entityType
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3313027092289172340, guid: aebcdae242e01f94b8df85895a81a0ff,
type: 3}
>>>>>>> Stashed changes
>>>>>>> AI
propertyPath: movingRange
value: 100
objectReference: {fileID: 0}
@ -800,11 +1169,99 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
- target: {fileID: 8179579322411983252, guid: aebcdae242e01f94b8df85895a81a0ff,
type: 3}
propertyPath: m_ApplyRootMotion
value: 0
objectReference: {fileID: 0}
>>>>>>> Stashed changes
>>>>>>> AI
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: aebcdae242e01f94b8df85895a81a0ff, type: 3}
<<<<<<< HEAD
=======
<<<<<<< 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
>>>>>>> AI
--- !u!1 &2031846085
GameObject:
m_ObjectHideFlags: 0
@ -878,12 +1335,26 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
m_LocalScale: {x: 151.85318, y: 76.588165, z: 323.46393}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4361362965383754916}
- {fileID: 1024498421}
- {fileID: 1125800493}
<<<<<<< HEAD
=======
=======
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4361362965383754916}
- {fileID: 682128552}
>>>>>>> Stashed changes
>>>>>>> AI
m_Father: {fileID: 543450651658663480}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &543450651658663480
@ -899,6 +1370,13 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
- {fileID: 1527981080}
>>>>>>> Stashed changes
>>>>>>> AI
- {fileID: 175694171717526785}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -932,6 +1410,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6da9430305b32f446a2517f4a73fdf57, type: 3}
m_Name:
m_EditorClassIdentifier:
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
acceleration: 30
turnAngle: 30
wheels:
@ -948,6 +1430,27 @@ MonoBehaviour:
wheelCollider: {fileID: 1574385376}
axel: 1
brakeForce: 100
<<<<<<< HEAD
=======
=======
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
>>>>>>> AI
braking: 0
--- !u!114 &919132148007562372
MonoBehaviour:
@ -961,6 +1464,16 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bc82a40176164f02897928bd573bc2ca, type: 3}
m_Name:
m_EditorClassIdentifier:
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
carPosition: {fileID: 175694171717526785}
stoppingDistance: 7
slowingSpeed: 5
slowingDistance: 30
>>>>>>> Stashed changes
>>>>>>> AI
--- !u!1 &1041543500241701263
GameObject:
m_ObjectHideFlags: 0
@ -1005,9 +1518,21 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7018000553910114355}
serializedVersion: 2
<<<<<<< HEAD
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}
=======
<<<<<<< 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
>>>>>>> AI
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -1054,9 +1579,21 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1041543500241701263}
serializedVersion: 2
<<<<<<< HEAD
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}
=======
<<<<<<< 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
>>>>>>> AI
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -1071,7 +1608,15 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
<<<<<<< HEAD
m_LocalScale: {x: 0.0065853084, y: 0.013056847, z: 0.003091535}
=======
<<<<<<< Updated upstream
m_LocalScale: {x: 0.0065853084, y: 0.013056847, z: 0.003091535}
=======
m_LocalScale: {x: 1, y: 1, z: 1}
>>>>>>> Stashed changes
>>>>>>> AI
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4102084789518556337}
@ -1196,9 +1741,21 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1582988942254250249}
serializedVersion: 2
<<<<<<< HEAD
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}
=======
<<<<<<< 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
>>>>>>> AI
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -1914,8 +2471,18 @@ BoxCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
<<<<<<< HEAD
m_Size: {x: 0.01, y: 0.014814308, z: 0.010120844}
m_Center: {x: 0, y: 0.004394592, z: 0.00006042119}
=======
<<<<<<< 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
>>>>>>> AI
--- !u!4 &8417055251110083872
Transform:
m_ObjectHideFlags: 0
@ -1924,9 +2491,21 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3543920631802817220}
serializedVersion: 2
<<<<<<< HEAD
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}
=======
<<<<<<< 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
>>>>>>> AI
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4361362965383754916}
@ -2015,6 +2594,13 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
>>>>>>> Stashed changes
>>>>>>> AI
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0

View file

@ -1,7 +1,15 @@
/*
* author: lin hengrui ryan
* date: 30/7/2024
<<<<<<< HEAD
* description: ai code for the different ai in the game
=======
<<<<<<< Updated upstream
* description: ai code for the different ai in the game
=======
* description: AI code for the different AI in the game
>>>>>>> Stashed changes
>>>>>>> AI
*/
using System.Collections;
@ -11,6 +19,10 @@
public class AI : MonoBehaviour
{
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
/// <summary>
/// the types of ai that this game object can be
/// </summary>
@ -29,6 +41,20 @@ public enum EntityType
/// to show the entity types in the inspector as a dropdown
/// </summary>
public EntityType entityType;
<<<<<<< HEAD
=======
=======
/// <summary>
/// to save resources when referring to the speed of this AI
/// </summary>
private static readonly int AnimatorSpeed = Animator.StringToHash("Speed");
>>>>>>> Stashed changes
>>>>>>> AI
/// <summary>
/// set the layers the AI can be on
@ -70,35 +96,82 @@ public enum EntityType
/// </summary>
private string _nextState;
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
>>>>>>> AI
/// <summary>
/// to set initial values
/// </summary>
public void Awake()
{
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
_agent = GetComponent<NavMeshAgent>();
if (entityType == EntityType.Human)
{
_animator = GetComponent<Animator>();
_currentState = "Strolling";
}
<<<<<<< HEAD
=======
=======
_agent = GetComponent<NavMeshAgent>();
_animator = GetComponent<Animator>();
_currentState = "Strolling";
>>>>>>> Stashed changes
>>>>>>> AI
_nextState = _currentState;
ChangeState();
}
/// <summary>
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
/// 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);
<<<<<<< HEAD
=======
=======
/// 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
>>>>>>> AI
_currentState = _nextState;
}
/// <summary>
/// to change the scene when needed
/// </summary>
<<<<<<< HEAD
public void ChangeState()
=======
<<<<<<< Updated upstream
public void ChangeState()
=======
private void ChangeState()
>>>>>>> Stashed changes
>>>>>>> AI
{
StartCoroutine(_currentState);
}
@ -128,7 +201,14 @@ private IEnumerator Strolling()
while (_currentState == "Strolling")
{
<<<<<<< HEAD
Debug.Log("strolling");
=======
<<<<<<< Updated upstream
Debug.Log("strolling");
=======
>>>>>>> Stashed changes
>>>>>>> AI
if (!_destinationPointSet)
SearchWalkPoint();
else
@ -141,4 +221,12 @@ private IEnumerator Strolling()
ChangeState();
}
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
>>>>>>> AI
}

View file

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

View file

@ -1,19 +1,153 @@
<<<<<<< HEAD
using System;
=======
<<<<<<< Updated upstream
using System;
=======
using System.Collections;
>>>>>>> Stashed changes
>>>>>>> AI
using UnityEngine;
public class AICar : MonoBehaviour
{
<<<<<<< HEAD
=======
<<<<<<< Updated upstream
>>>>>>> AI
private CarController _carController;
private void Awake()
{
_carController = GetComponent<CarController>();
<<<<<<< HEAD
=======
=======
[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
>>>>>>> AI
}
private void Update()
{
<<<<<<< HEAD
float forwardAmount = 1f;
float turnAmount = 1f;
_carController.SetInputs(forwardAmount,turnAmount);
=======
<<<<<<< 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
>>>>>>> AI
}
}