Beating-With-Sticks: Created AIScript, AI moves

randomly and runs away from player when close.
Added NavMesh to scene. Updated documentation and tags.
This commit is contained in:
Santi 2024-08-07 12:37:51 +01:00
parent f11b769bfb
commit d00afd6a48
13 changed files with 565 additions and 127 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e225693e2679fa64eaee41733ef14697
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -122,7 +122,7 @@ NavMeshSettings:
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
m_NavMeshData: {fileID: 23800000, guid: ad41150ae7e034348ad7e7be379d8056, type: 2}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
@ -215,9 +215,9 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &765999529
--- !u!1 &1423233316
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -225,26 +225,109 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 765999533}
- component: {fileID: 765999532}
- component: {fileID: 765999531}
- component: {fileID: 765999530}
- component: {fileID: 765999535}
- component: {fileID: 765999534}
m_Layer: 0
- component: {fileID: 1423233324}
- component: {fileID: 1423233323}
- component: {fileID: 1423233322}
- component: {fileID: 1423233321}
- component: {fileID: 1423233320}
- component: {fileID: 1423233319}
- component: {fileID: 1423233318}
- component: {fileID: 1423233317}
m_Layer: 3
m_Name: Capsule
m_TagString: Untagged
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!136 &765999530
--- !u!143 &1423233317
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423233316}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &1423233318
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423233316}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 0
--- !u!114 &1423233319
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423233316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eca94ba4e2f880644ab196f816624ee6, type: 3}
m_Name:
m_EditorClassIdentifier:
carryPosition: {fileID: 0}
insideTrigger: 0
playerIsCarrying: 0
nearestCarriableObject: {fileID: 0}
previousObject: {fileID: 0}
heldObject: {fileID: 0}
throwForce: 5
cooldownSeconds: 1
cooldownActive: 0
interactKey: 102
--- !u!114 &1423233320
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1423233316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 93424cdca660b854faec02bc3325bc31, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 5
turnSpeed: 720
sprintSpeed: 10
jumpForce: 2.5
gravity: 9.8
throwForce: {fileID: 1423233319}
forwardsKey: 119
backwardsKey: 115
leftKey: 97
rightKey: 101
sprintKey: 304
jumpKey: 32
hammer: 0
--- !u!136 &1423233321
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765999529}
m_GameObject: {fileID: 1423233316}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
@ -252,13 +335,13 @@ CapsuleCollider:
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &765999531
--- !u!23 &1423233322
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765999529}
m_GameObject: {fileID: 1423233316}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
@ -294,72 +377,30 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &765999532
--- !u!33 &1423233323
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765999529}
m_GameObject: {fileID: 1423233316}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &765999533
--- !u!4 &1423233324
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765999529}
m_GameObject: {fileID: 1423233316}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.21045552, y: 2.21, z: 0.096935526}
m_LocalPosition: {x: -8.31, y: 2, z: 6.61}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!143 &765999534
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765999529}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &765999535
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 765999529}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 93424cdca660b854faec02bc3325bc31, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 5
turnSpeed: 0
sprintSpeed: 10
jumpForce: 5
gravity: 9.8
throwForce: {fileID: 0}
forwardsKey: 119
backwardsKey: 115
leftKey: 97
rightKey: 100
sprintKey: 304
jumpKey: 32
--- !u!1 &963194225
--- !u!1 &1664811009
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -367,82 +408,151 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
- component: {fileID: 1664811013}
- component: {fileID: 1664811012}
- component: {fileID: 1664811011}
- component: {fileID: 1664811010}
- component: {fileID: 1664811014}
- component: {fileID: 1664811015}
- component: {fileID: 1664811016}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Name: Sphere
m_TagString: Touch
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &963194226
AudioListener:
--- !u!135 &1664811010
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!20 &963194227
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_GameObject: {fileID: 1664811009}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &963194228
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1664811011
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1664811009}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1664811012
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1664811009}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1664811013
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 11.79, z: 0}
m_GameObject: {fileID: 1664811009}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.42, y: 3.24, z: -8.59}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!195 &1664811014
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1664811009}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 5
m_Acceleration: 8
avoidancePriority: 50
m_AngularSpeed: 120
m_StoppingDistance: 0
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 1
m_BaseOffset: 0.5
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!114 &1664811015
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1664811009}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b478d0ab1ff19cb4cb9e6161ea2a14d5, type: 3}
m_Name:
m_EditorClassIdentifier:
player: {fileID: 0}
agent: {fileID: 0}
walkPoint: {x: 0, y: 0, z: 0}
walkPointSet: 0
walkPointRange: 7
playerInSightRange: 0
--- !u!135 &1664811016
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1664811009}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 9
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &1947815994
GameObject:
m_ObjectHideFlags: 0
@ -460,7 +570,7 @@ GameObject:
m_TagString: Floor
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 40
m_IsActive: 1
--- !u!23 &1947815996
MeshRenderer:
@ -521,11 +631,11 @@ Transform:
m_GameObject: {fileID: 1947815994}
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_LocalScale: {x: 2, y: 1, z: 2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!64 &1947815999
MeshCollider:
@ -541,3 +651,166 @@ MeshCollider:
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &2064354429
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2064354434}
- component: {fileID: 2064354433}
- component: {fileID: 2064354432}
- component: {fileID: 2064354431}
- component: {fileID: 2064354430}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2064354430
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064354429}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
m_Name:
m_EditorClassIdentifier:
sharedProfile: {fileID: 11400000, guid: 3c8dc5f9b0a9b3746a34c440291297b3, type: 2}
isGlobal: 1
blendDistance: 0
weight: 1
priority: 0
--- !u!114 &2064354431
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064354429}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
m_Name:
m_EditorClassIdentifier:
volumeTrigger: {fileID: 2064354434}
volumeLayer:
serializedVersion: 2
m_Bits: 4294967295
stopNaNPropagation: 1
finalBlitToCameraTarget: 0
antialiasingMode: 0
temporalAntialiasing:
jitterSpread: 0.75
sharpness: 0.25
stationaryBlending: 0.95
motionBlending: 0.85
subpixelMorphologicalAntialiasing:
quality: 2
fastApproximateAntialiasing:
fastMode: 0
keepAlpha: 0
fog:
enabled: 1
excludeSkybox: 1
debugLayer:
lightMeter:
width: 512
height: 256
showCurves: 1
histogram:
width: 512
height: 256
channel: 3
waveform:
exposure: 0.12
height: 256
vectorscope:
size: 256
exposure: 0.12
overlaySettings:
linearDepth: 0
motionColorIntensity: 4
motionGridSize: 64
colorBlindnessType: 0
colorBlindnessStrength: 1
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
m_ShowToolkit: 0
m_ShowCustomSorter: 0
breakBeforeColorGrading: 0
m_BeforeTransparentBundles: []
m_BeforeStackBundles: []
m_AfterStackBundles: []
--- !u!81 &2064354432
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064354429}
m_Enabled: 1
--- !u!20 &2064354433
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064354429}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 36
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &2064354434
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064354429}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0.42, y: 28.94, z: -0.09}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ad41150ae7e034348ad7e7be379d8056
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 23800000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e039091e66d77cf47a998fb931c89317
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a389199382966ca4d8633d20a83e0eca
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 23800000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c2e3b1de8c68c5f49880cb3e8ef7d3c9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,113 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
//TODO AI Script for the Stick Beating Game
//* AI for enemies to run away from the character once in range
//* AI should change direction every few seconds to make it harder for the player to hit them
//TODO AI should not go into a direction within the player's range
//* If player is not in range, AI should move randomly
public class AIScript : MonoBehaviour
{
private bool runningCoroutine = false;
public GameObject player;
public NavMeshAgent agent;
//* Patroling
public Vector3 walkPoint;
public bool walkPointSet;
public float walkPointRange;
//* States
public bool playerInSightRange = false;
void Start()
{
player = GameObject.Find("Capsule");
agent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
if(!playerInSightRange) Patroling();
if(playerInSightRange) Running();
}
private void Patroling()
{
agent.speed = 3.5f;
if(!walkPointSet) SetWalkPointPatroling();
if(walkPointSet)
agent.SetDestination(walkPoint);
Vector3 distanceToWalkPoint = transform.position - walkPoint;
if(distanceToWalkPoint.magnitude < 1f)
walkPointSet = false;
}
private void SetWalkPointPatroling()
{
float randomZ = Random.Range(-walkPointRange, walkPointRange);
float randomX = Random.Range(-walkPointRange, walkPointRange);
walkPoint = new Vector3(randomX, transform.position.y, randomZ);
walkPointSet = true;
}
private void Running()
{
agent.speed = 6f;
if(!walkPointSet) SetWalkPointRunning();
if(walkPointSet)
agent.SetDestination(walkPoint);
if(!runningCoroutine) StartCoroutine(WaitTime());
Vector3 distanceToWalkPoint = transform.position - walkPoint;
if(distanceToWalkPoint.magnitude < 1f)
walkPointSet = false;
}
private void SetWalkPointRunning()
{
float randomZ = Random.Range(-walkPointRange, walkPointRange);
float randomX = Random.Range(-walkPointRange, walkPointRange);
walkPoint = new Vector3(randomX, transform.position.y, randomZ);
walkPointSet = true;
}
IEnumerator WaitTime()
{
runningCoroutine = true;
yield return new WaitForSeconds(Random.Range(2, 5));
walkPointSet = false;
runningCoroutine = false;
}
private void OnTriggerEnter(Collider other) {
if(other.gameObject == player)
{
playerInSightRange = true;
}
}
private void OnTriggerExit(Collider other) {
if(other.gameObject == player)
{
playerInSightRange = false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b478d0ab1ff19cb4cb9e6161ea2a14d5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,11 +2,11 @@ Beating With Sticks
Beating with sticks is a minigame where the player is given a big long stick
they drag around and are tasked with beating the ever loving shit out of
other people. This can be other players if thats every implemented, enemy
Ais that are also trying to beat you to death, or animals or something like
other people. This can be other players if thats ever implemented, enemy
AIs that are also trying to beat you to death, or animals or something like
that which will run from you. If its against animals or AIs that dont fight
back, the player can click on them every few seconds to stun them. Maybe
a rock is thrown in their direction. The player will either need to get all Ais
a rock is thrown in their direction. The player will either need to get all AIs
before a time limit or be the last one standing.
>[!NOTE] Beating With Sticks Concept Art

View File

@ -10,11 +10,12 @@ TagManager:
- Container
- Bomb
- SpecialObject
- Touch
layers:
- Default
- TransparentFX
- Ignore Raycast
-
- Player
- Water
- UI
-