make working enermy with ai

This commit is contained in:
Sc0rch-thinks 2024-07-02 10:42:09 +08:00
parent 77e4b75e4f
commit 604d592ee8
19 changed files with 2341 additions and 240 deletions

View file

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 6916749199650078309}
- component: {fileID: 2578125575657415053}
- component: {fileID: 6778915936728483955}
- component: {fileID: 2372079994149255709}
m_Layer: 0
m_Name: Bullet
m_TagString: Untagged
@ -133,3 +134,17 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &2372079994149255709
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 634305283682154916}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 69125b331043ed74c8631d9a8966bbbb, type: 3}
m_Name:
m_EditorClassIdentifier:
damage: 65
lifespan: 5

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0cb9e1bb0725a89488a294c55923e082
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -589,7 +589,7 @@ Transform:
m_GameObject: {fileID: 3366665043858970863}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 633.38696, y: 53.228, z: 712.275}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:

View file

@ -377,6 +377,38 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 367155638}
m_CullTransparentMesh: 1
--- !u!1 &376520021
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 376520022}
m_Layer: 8
m_Name: hand
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &376520022
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 376520021}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.569, y: 0, z: 0.253}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5722651808059730734}
m_Father: {fileID: 7523861224561778816}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &565925926 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 253673096910479318, guid: fcc3124eb1a35354d8faf61ffa67d814,
@ -406,7 +438,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &870943463
Transform:
m_ObjectHideFlags: 0
@ -430,7 +462,7 @@ VFXRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 870943462}
m_Enabled: 1
m_Enabled: 0
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
@ -623,7 +655,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1084962702}
m_Layer: 8
m_Layer: 7
m_Name: hand position
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -760,6 +792,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
playerCamera: {fileID: 781711374}
seeDistance: 5
CurrentGun: {fileID: 0}
holdingGun: {fileID: 0}
hand: {fileID: 1084962701}
--- !u!4 &1312533610 stripped
Transform:
@ -812,6 +846,21 @@ PrefabInstance:
propertyPath: SprintSpeed
value: 20
objectReference: {fileID: 0}
- target: {fileID: 453084650579209855, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 2351121289802177058, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 2862278905431641492, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 2862278905431641495, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: CameraDistance
@ -827,6 +876,16 @@ PrefabInstance:
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2862278905927073192, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4253012990419024489, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4253012990419024491, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Enabled
@ -867,6 +926,11 @@ PrefabInstance:
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 5126527961139664765, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 5126527961139664767, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: field of view
@ -892,6 +956,11 @@ PrefabInstance:
propertyPath: m_BackGroundColor.r
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5242107653240477476, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 6556307555316582679, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_LocalPosition.x
@ -947,6 +1016,11 @@ PrefabInstance:
propertyPath: m_Name
value: NestedParent_Unpack
objectReference: {fileID: 0}
- target: {fileID: 7094977340588366727, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_Layer
value: 7
objectReference: {fileID: 0}
- target: {fileID: 7094977340588366727, guid: 035bf1ba97d19214580cfe6f5a29fdc3,
type: 3}
propertyPath: m_IsActive
@ -974,6 +1048,69 @@ PrefabInstance:
insertIndex: -1
addedObject: {fileID: 1312533616}
m_SourcePrefab: {fileID: 100100000, guid: 035bf1ba97d19214580cfe6f5a29fdc3, type: 3}
--- !u!1 &1560936834
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1560936836}
- component: {fileID: 1560936835}
m_Layer: 0
m_Name: navMesh
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1560936835
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1560936834}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AgentTypeID: 0
m_CollectObjects: 0
m_Size: {x: 10, y: 10, z: 10}
m_Center: {x: 0, y: 2, z: 0}
m_LayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_UseGeometry: 0
m_DefaultArea: 0
m_GenerateLinks: 1
m_IgnoreNavMeshAgent: 1
m_IgnoreNavMeshObstacle: 1
m_OverrideTileSize: 0
m_TileSize: 256
m_OverrideVoxelSize: 0
m_VoxelSize: 0.16666667
m_MinRegionArea: 2
m_NavMeshData: {fileID: 23800000, guid: 9ce6c8e041f4a72418bd35bc47b82f64, type: 2}
m_BuildHeightMesh: 0
--- !u!4 &1560936836
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1560936834}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 632.8, y: 53.06, z: 707.66}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1880143511
GameObject:
m_ObjectHideFlags: 0
@ -985,7 +1122,7 @@ GameObject:
- component: {fileID: 1880143514}
- component: {fileID: 1880143513}
- component: {fileID: 1880143512}
m_Layer: 0
m_Layer: 8
m_Name: Terrain
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -1066,6 +1203,43 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1888931747
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1888931748}
m_Layer: 8
m_Name: refrence
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1888931748
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1888931747}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.373, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7523861224561778816}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4909242260980625812 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7938632458746094310, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
m_PrefabInstance: {fileID: 7852504279946953677}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &5691261327966626505
PrefabInstance:
m_ObjectHideFlags: 0
@ -1134,6 +1308,12 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5fb943f0c37a29e4ab9d29553d613711, type: 3}
--- !u!4 &5722651808059730734 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
m_PrefabInstance: {fileID: 7852504279946953677}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6704506024639312884
PrefabInstance:
m_ObjectHideFlags: 0
@ -1185,7 +1365,7 @@ PrefabInstance:
- target: {fileID: 2734560914043830869, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
value: 0.77285933
objectReference: {fileID: 0}
- target: {fileID: 2734560914043830869, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
@ -1200,7 +1380,7 @@ PrefabInstance:
- target: {fileID: 2734560914043830869, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
value: 0.63457745
objectReference: {fileID: 0}
- target: {fileID: 2734560914043830869, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
@ -1215,7 +1395,7 @@ PrefabInstance:
- target: {fileID: 2734560914043830869, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
value: 78.777
objectReference: {fileID: 0}
- target: {fileID: 3366665043858970863, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
@ -1227,6 +1407,16 @@ PrefabInstance:
propertyPath: mag
value:
objectReference: {fileID: 565925926}
- target: {fileID: 8616388319935238913, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
propertyPath: fire
value:
objectReference: {fileID: 870943465}
- target: {fileID: 8616388319935238913, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
propertyPath: range
value: 120
objectReference: {fileID: 0}
- target: {fileID: 8616388319935238913, guid: fcc3124eb1a35354d8faf61ffa67d814,
type: 3}
propertyPath: fpsCam
@ -1257,6 +1447,243 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 6704506024639312884}
m_PrefabAsset: {fileID: 0}
--- !u!4 &7523861224561778816
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7523861224561778819}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 567.83887, y: 53.005142, z: 599.395}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 376520022}
- {fileID: 1888931748}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &7523861224561778817
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7523861224561778819}
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: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &7523861224561778819
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7523861224561778816}
- component: {fileID: 7523861224561778831}
- component: {fileID: 7523861224561778830}
- component: {fileID: 7523861224561778817}
- component: {fileID: 7523861224561778833}
- component: {fileID: 7523861224561778834}
m_Layer: 8
m_Name: Capsule
m_TagString: enemy
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &7523861224561778830
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7523861224561778819}
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: 2100000, guid: 6b911390c5825014e8377183a7837d3f, type: 2}
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 &7523861224561778831
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7523861224561778819}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &7523861224561778833
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7523861224561778819}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c199db931449c5a43aeac4001b086a95, type: 3}
m_Name:
m_EditorClassIdentifier:
agent: {fileID: 7523861224561778834}
player: {fileID: 1312533610}
groundMask:
serializedVersion: 2
m_Bits: 256
playerMask:
serializedVersion: 2
m_Bits: 128
health: 100
WalkPoint: {x: 0, y: 0, z: 0}
walkRange: 25
sightRange: 25
attackRange: 15
gun: {fileID: 4909242260980625812}
--- !u!195 &7523861224561778834
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7523861224561778819}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 3.5
m_Acceleration: 8
avoidancePriority: 50
m_AngularSpeed: 120
m_StoppingDistance: 0
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 2
m_BaseOffset: 1
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!1001 &7852504279946953677
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 376520022}
m_Modifications:
- target: {fileID: 3270813210746987743, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_IsKinematic
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4049575175909728394, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6064497003828031006, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: fpsCam
value:
objectReference: {fileID: 1888931748}
- target: {fileID: 7938632458746094310, guid: 0cb9e1bb0725a89488a294c55923e082,
type: 3}
propertyPath: m_Name
value: enemyGun
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0cb9e1bb0725a89488a294c55923e082, type: 3}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
@ -1268,3 +1695,5 @@ SceneRoots:
- {fileID: 6704506024639312884}
- {fileID: 1326803979}
- {fileID: 5691261327966626505}
- {fileID: 7523861224561778816}
- {fileID: 1560936836}

Binary file not shown.

View file

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

39
Assets/Scripts/Bullet.cs Normal file
View file

@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class BulletCollider : MonoBehaviour
{
public int damage;
public float lifespan;
void OnCollisionEnter(Collision other)
{
Debug.Log("nf");
if (other.transform.tag == "Player")
{
GameManager.instance.damagePlayer(damage);
}
else if(other.transform.tag=="enemy")
{
other.transform.GetComponent<EnemyAi>().health-=damage;
if(other.transform.GetComponent<EnemyAi>().health<=0)
{
Destroy(other.gameObject);
}
}
}
void Update()
{
lifespan-=Time.deltaTime;
if(lifespan<=0)
{
killBullet();
}
}
public void killBullet()
{
Destroy(gameObject);
}
}

View file

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

View file

@ -13,7 +13,8 @@ public class CharacterControl : MonoBehaviour
float seeDistance;
Interactable curretInteractable;
Pickable currentPickable;
Gun CurrentGun=null;
public GunPickable CurrentGun;
public GameObject holdingGun;
public RaycastHit hitInfo;
public static bool handsFull;
@ -37,10 +38,7 @@ void Update()
{
Debug.Log(hitInfo.transform.name);
if (hitInfo.transform.TryGetComponent<Interactable>(out curretInteractable)) { }
else if (hitInfo.transform.TryGetComponent<Pickable>(out currentPickable))
{
if (hitInfo.transform.TryGetComponent<Gun>(out CurrentGun)) { }
}
else if (hitInfo.transform.TryGetComponent<Pickable>(out currentPickable)) { }
else
{
curretInteractable = null;
@ -63,6 +61,10 @@ void OnInteract()
if (currentPickable != null)
{
currentPickable.PickUp();
if (currentPickable.TryGetComponent<GunPickable>(out CurrentGun))
{
holdingGun = CurrentGun.gameObject;
}
}
}
@ -71,8 +73,7 @@ void OnShoot()
Debug.Log("Shoot");
if (CurrentGun != null)
{
CurrentGun.Shoot();
CurrentGun.GetComponent<Gun>().Shoot();
}
}
@ -80,7 +81,7 @@ void OnReload()
{
if (CurrentGun != null)
{
CurrentGun.Reload();
CurrentGun.GetComponent<Gun>().Reload();
}
}

107
Assets/Scripts/EnemyAi.cs Normal file
View file

@ -0,0 +1,107 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;
public class EnemyAi : MonoBehaviour
{
public NavMeshAgent agent;
public Transform player;
public LayerMask groundMask;
public LayerMask playerMask;
public int health = 100;
/// <summary>
/// patrol variables
/// </summary>
public Vector3 WalkPoint;
private bool walkPointSet = false;
public float walkRange;
public float sightRange;
public float attackRange;
private bool playerInSightRange;
private bool playerInAttackRange;
public GameObject gun;
void Update()
{
//Check for sight and attack range
playerInSightRange = Physics.CheckSphere(transform.position, sightRange, playerMask);
playerInAttackRange = Physics.CheckSphere(transform.position, attackRange, playerMask);
if (!playerInSightRange && !playerInAttackRange)
Patrol();
if (playerInSightRange && !playerInAttackRange)
Chase();
if (playerInAttackRange && playerInSightRange)
Attack();
if (health <= 0)
{
Destroy(gameObject);
}
}
private void Patrol()
{
Debug.Log("Patroling");
if (!walkPointSet)
{
SeachWalkPoint();
}
else
{
agent.SetDestination(WalkPoint);
}
;
Vector3 distaceToWalk = transform.position - WalkPoint;
if (distaceToWalk.magnitude < 1f)
walkPointSet = false;
}
private void SeachWalkPoint()
{
float randomZ = Random.Range(-walkRange, walkRange);
float randomX = Random.Range(-walkRange, walkRange);
WalkPoint = new Vector3(
transform.position.x + randomX,
transform.position.y,
transform.position.z + randomZ
);
if (Physics.Raycast(WalkPoint, -transform.up, 2f, groundMask))
{
walkPointSet = true;
}
}
private void Chase()
{
Debug.Log("chasing");
agent.SetDestination(player.position);
}
private void Attack()
{
Debug.Log("Attacking");
agent.SetDestination(transform.position);
transform.LookAt(player);
gun.GetComponent<enemyGun>().Shoot();
}
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, sightRange);
}
}

View file

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

View file

@ -19,4 +19,8 @@ void Awake()
}
}
public int playerHealth = 100;
public void damagePlayer(int damage)
{
playerHealth-=damage;
}
}

View file

@ -53,9 +53,13 @@ public void Shoot()
RaycastHit hit;
Vector3 targetPoint;
if (Physics.Raycast(ray, out hit))
{targetPoint = hit.point;}
{
targetPoint = hit.point;
}
else
{targetPoint = ray.GetPoint(150);}
{
targetPoint = ray.GetPoint(150);
}
Vector3 direction = targetPoint - bulletSpawn.position;
GameObject currentBullet = Instantiate(
@ -63,6 +67,7 @@ public void Shoot()
bulletSpawn.position,
Quaternion.identity
);
currentBullet.GetComponent<BulletCollider>().damage = damage;
currentBullet.transform.forward = direction.normalized;
currentBullet
.GetComponent<Rigidbody>()
@ -83,6 +88,7 @@ void Update()
Reload();
}
}
private void ResetShot()
{
//Allow shooting and invoking again

106
Assets/Scripts/enemyGun.cs Normal file
View file

@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class enemyGun : MonoBehaviour
{
public GameObject bullet;
/// <summary>
/// gun stats
/// </summary>
public int magSize;
public int damage;
public float timeBtwShots;
public float range;
public float reloadTime;
public int bulletsPerFire;
public bool automaticFire;
/// <summary>
/// gun status
/// </summary>
private bool reloading;
private bool shooting;
private bool readyToShot;
private int bulletsLeft;
/// <summary>
/// Refrencing
/// </summary>
[SerializeField]
Transform fpsCam;
public Transform bulletSpawn;
public bool allowInvoke = true;
[SerializeField]
private GameObject mag;
void Awake()
{
bulletsLeft = magSize;
readyToShot = true;
}
public void Shoot()
{
if (readyToShot && !reloading && bulletsLeft > 0)
{
Debug.Log("Bang");
readyToShot=false;
GameObject currentBullet = Instantiate(
bullet,
bulletSpawn.position,
Quaternion.identity
);
currentBullet.GetComponent<BulletCollider>().damage=damage;
currentBullet
.GetComponent<Rigidbody>()
.AddForce(transform.forward * range, ForceMode.Impulse);
bulletsLeft--;
if (allowInvoke)
{
Invoke("ResetShot", timeBtwShots);
allowInvoke = false;
}
}
}
void Update()
{
if(bulletsLeft == 0)
{
Reload();
}
}
private void ResetShot()
{
//Allow shooting and invoking again
readyToShot = true;
allowInvoke = true;
}
public void Reload()
{
if (bulletsLeft < magSize && !reloading)
{
Debug.Log("reload");
reloading = true;
readyToShot = false;
Invoke("Reloaded", reloadTime);
mag.SetActive(false);
}
}
void Reloaded()
{
reloading = false;
readyToShot = true;
bulletsLeft = magSize;
mag.SetActive(true);
}
}

View file

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

View file

@ -14,40 +14,60 @@ public class FirstPersonController : MonoBehaviour
[Header("Player")]
[Tooltip("Move speed of the character in m/s")]
public float MoveSpeed = 4.0f;
[Tooltip("Sprint speed of the character in m/s")]
public float SprintSpeed = 6.0f;
[Tooltip("Rotation speed of the character")]
public float RotationSpeed = 1.0f;
[Tooltip("Acceleration and deceleration")]
public float SpeedChangeRate = 10.0f;
[Space(10)]
[Tooltip("The height the player can jump")]
public float JumpHeight = 1.2f;
[Tooltip("The character uses its own gravity value. The engine default is -9.81f")]
public float Gravity = -15.0f;
[Space(10)]
[Tooltip("Time required to pass before being able to jump again. Set to 0f to instantly jump again")]
[Tooltip(
"Time required to pass before being able to jump again. Set to 0f to instantly jump again"
)]
public float JumpTimeout = 0.1f;
[Tooltip("Time required to pass before entering the fall state. Useful for walking down stairs")]
[Tooltip(
"Time required to pass before entering the fall state. Useful for walking down stairs"
)]
public float FallTimeout = 0.15f;
[Header("Player Grounded")]
[Tooltip("If the character is grounded or not. Not part of the CharacterController built in grounded check")]
[Tooltip(
"If the character is grounded or not. Not part of the CharacterController built in grounded check"
)]
public bool Grounded = true;
[Tooltip("Useful for rough ground")]
public float GroundedOffset = -0.14f;
[Tooltip("The radius of the grounded check. Should match the radius of the CharacterController")]
[Tooltip(
"The radius of the grounded check. Should match the radius of the CharacterController"
)]
public float GroundedRadius = 0.5f;
[Tooltip("What layers the character uses as ground")]
public LayerMask GroundLayers;
[Header("Cinemachine")]
[Tooltip("The follow target set in the Cinemachine Virtual Camera that the camera will follow")]
[Tooltip(
"The follow target set in the Cinemachine Virtual Camera that the camera will follow"
)]
public GameObject CinemachineCameraTarget;
[Tooltip("How far in degrees can you move the camera up")]
public float TopClamp = 90.0f;
[Tooltip("How far in degrees can you move the camera down")]
public float BottomClamp = -90.0f;
@ -64,7 +84,6 @@ public class FirstPersonController : MonoBehaviour
private float _jumpTimeoutDelta;
private float _fallTimeoutDelta;
#if ENABLE_INPUT_SYSTEM
private PlayerInput _playerInput;
#endif
@ -102,7 +121,9 @@ private void Start()
#if ENABLE_INPUT_SYSTEM
_playerInput = GetComponent<PlayerInput>();
#else
Debug.LogError( "Starter Assets package is missing dependencies. Please use Tools/Starter Assets/Reinstall Dependencies to fix it");
Debug.LogError(
"Starter Assets package is missing dependencies. Please use Tools/Starter Assets/Reinstall Dependencies to fix it"
);
#endif
// reset our timeouts on start
@ -125,8 +146,17 @@ private void LateUpdate()
private void GroundedCheck()
{
// set sphere position, with offset
Vector3 spherePosition = new Vector3(transform.position.x, transform.position.y - GroundedOffset, transform.position.z);
Grounded = Physics.CheckSphere(spherePosition, GroundedRadius, GroundLayers, QueryTriggerInteraction.Ignore);
Vector3 spherePosition = new Vector3(
transform.position.x,
transform.position.y - GroundedOffset,
transform.position.z
);
Grounded = Physics.CheckSphere(
spherePosition,
GroundedRadius,
GroundLayers,
QueryTriggerInteraction.Ignore
);
}
private void CameraRotation()
@ -141,10 +171,18 @@ private void CameraRotation()
_rotationVelocity = _input.look.x * RotationSpeed * deltaTimeMultiplier;
// clamp our pitch rotation
_cinemachineTargetPitch = ClampAngle(_cinemachineTargetPitch, BottomClamp, TopClamp);
_cinemachineTargetPitch = ClampAngle(
_cinemachineTargetPitch,
BottomClamp,
TopClamp
);
// Update Cinemachine camera target pitch
CinemachineCameraTarget.transform.localRotation = Quaternion.Euler(_cinemachineTargetPitch, 0.0f, 0.0f);
CinemachineCameraTarget.transform.localRotation = Quaternion.Euler(
_cinemachineTargetPitch,
0.0f,
0.0f
);
// rotate the player left and right
transform.Rotate(Vector3.up * _rotationVelocity);
@ -160,20 +198,32 @@ private void Move()
// note: Vector2's == operator uses approximation so is not floating point error prone, and is cheaper than magnitude
// if there is no input, set the target speed to 0
if (_input.move == Vector2.zero) targetSpeed = 0.0f;
if (_input.move == Vector2.zero)
targetSpeed = 0.0f;
// a reference to the players current horizontal velocity
float currentHorizontalSpeed = new Vector3(_controller.velocity.x, 0.0f, _controller.velocity.z).magnitude;
float currentHorizontalSpeed = new Vector3(
_controller.velocity.x,
0.0f,
_controller.velocity.z
).magnitude;
float speedOffset = 0.1f;
float inputMagnitude = _input.analogMovement ? _input.move.magnitude : 1f;
// accelerate or decelerate to target speed
if (currentHorizontalSpeed < targetSpeed - speedOffset || currentHorizontalSpeed > targetSpeed + speedOffset)
if (
currentHorizontalSpeed < targetSpeed - speedOffset
|| currentHorizontalSpeed > targetSpeed + speedOffset
)
{
// creates curved result rather than a linear one giving a more organic speed change
// note T in Lerp is clamped, so we don't need to clamp our speed
_speed = Mathf.Lerp(currentHorizontalSpeed, targetSpeed * inputMagnitude, Time.deltaTime * SpeedChangeRate);
_speed = Mathf.Lerp(
currentHorizontalSpeed,
targetSpeed * inputMagnitude,
Time.deltaTime * SpeedChangeRate
);
// round speed to 3 decimal places
_speed = Mathf.Round(_speed * 1000f) / 1000f;
@ -191,11 +241,15 @@ private void Move()
if (_input.move != Vector2.zero)
{
// move
inputDirection = transform.right * _input.move.x + transform.forward * _input.move.y;
inputDirection =
transform.right * _input.move.x + transform.forward * _input.move.y;
}
// move the player
_controller.Move(inputDirection.normalized * (_speed * Time.deltaTime) + new Vector3(0.0f, _verticalVelocity, 0.0f) * Time.deltaTime);
_controller.Move(
inputDirection.normalized * (_speed * Time.deltaTime)
+ new Vector3(0.0f, _verticalVelocity, 0.0f) * Time.deltaTime
);
}
private void JumpAndGravity()
@ -248,8 +302,10 @@ private void JumpAndGravity()
private static float ClampAngle(float lfAngle, float lfMin, float lfMax)
{
if (lfAngle < -360f) lfAngle += 360f;
if (lfAngle > 360f) lfAngle -= 360f;
if (lfAngle < -360f)
lfAngle += 360f;
if (lfAngle > 360f)
lfAngle -= 360f;
return Mathf.Clamp(lfAngle, lfMin, lfMax);
}
@ -258,11 +314,20 @@ private void OnDrawGizmosSelected()
Color transparentGreen = new Color(0.0f, 1.0f, 0.0f, 0.35f);
Color transparentRed = new Color(1.0f, 0.0f, 0.0f, 0.35f);
if (Grounded) Gizmos.color = transparentGreen;
else Gizmos.color = transparentRed;
if (Grounded)
Gizmos.color = transparentGreen;
else
Gizmos.color = transparentRed;
// when selected, draw a gizmo in the position of, and matching radius of, the grounded collider
Gizmos.DrawSphere(new Vector3(transform.position.x, transform.position.y - GroundedOffset, transform.position.z), GroundedRadius);
Gizmos.DrawSphere(
new Vector3(
transform.position.x,
transform.position.y - GroundedOffset,
transform.position.z
),
GroundedRadius
);
}
}
}

View file

@ -71,7 +71,7 @@ NavMeshProjectSettings:
cost: 1
m_LastAgentTypeID: -887442657
m_Settings:
- serializedVersion: 2
- serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
@ -84,7 +84,9 @@ NavMeshProjectSettings:
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_SettingNames:

View file

@ -5,6 +5,7 @@ TagManager:
serializedVersion: 2
tags:
- CinemachineTarget
- enemy
layers:
- Default
- TransparentFX
@ -13,8 +14,8 @@ TagManager:
- Water
- UI
- isInteractable
-
-
- player
- terrain
-
-
-