발사
발사라던가 제작했습니다만 .. 데미지 구현은 모르겠고 큐 효율성을 높여주세요
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"name": "InputSystem_Actions",
|
||||
"maps": [
|
||||
{
|
||||
@@ -85,6 +86,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Mouse",
|
||||
"type": "Value",
|
||||
"id": "24341b02-824d-4fad-9ca4-b13eb0e8d4e7",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -472,6 +482,17 @@
|
||||
"action": "Crouch",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "37f6f208-f780-4e98-829e-c0037bea0fe7",
|
||||
"path": "<Mouse>/position",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": ";Keyboard&Mouse",
|
||||
"action": "Mouse",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ ScriptedImporter:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 0
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath: Assets/Scripts/InputSystem.cs
|
||||
wrapperClassName: InputSystem
|
||||
wrapperCodeNamespace:
|
||||
|
||||
8
Assets/Prefabs.meta
Normal file
8
Assets/Prefabs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 789f0212fbad5b34190229bfd3fd1316
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
154
Assets/Prefabs/Bullet.prefab
Normal file
154
Assets/Prefabs/Bullet.prefab
Normal file
@@ -0,0 +1,154 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3217186003837015034
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 20945486064176397}
|
||||
- component: {fileID: 128695639235310656}
|
||||
- component: {fileID: 6310722883206932060}
|
||||
- component: {fileID: 1818131859172166424}
|
||||
m_Layer: 7
|
||||
m_Name: Bullet
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &20945486064176397
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3217186003837015034}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0.12751925, w: 0.9918362}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.05, y: 0.1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -14.653}
|
||||
--- !u!212 &128695639235310656
|
||||
SpriteRenderer:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3217186003837015034}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, 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: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_MaskInteraction: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &6310722883206932060
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3217186003837015034}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 80aae26211daf7b4d9f8f603e7c6987f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::BulletMovement
|
||||
moveSpeed: 10
|
||||
--- !u!61 &1818131859172166424
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3217186003837015034}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_ForceSendLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ForceReceiveLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ContactCaptureLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_CallbackLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_CompositeOperation: 0
|
||||
m_CompositeOrder: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 1, y: 1}
|
||||
newSize: {x: 1, y: 1}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_EdgeRadius: 0
|
||||
7
Assets/Prefabs/Bullet.prefab.meta
Normal file
7
Assets/Prefabs/Bullet.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 204cdd5e6f663694d8d6e719543b2018
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -119,6 +119,97 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &8217829
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8217830}
|
||||
- component: {fileID: 8217831}
|
||||
m_Layer: 0
|
||||
m_Name: AnglePoint
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8217830
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8217829}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
||||
m_LocalScale: {x: 0.25, y: 0.25, z: 0.25}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1146100370}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &8217831
|
||||
SpriteRenderer:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8217829}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, 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: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_MaskInteraction: 0
|
||||
m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &519420028
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -340,7 +431,7 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &997674418
|
||||
--- !u!1 &1146100368
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -348,25 +439,24 @@ GameObject:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 997674420}
|
||||
- component: {fileID: 997674419}
|
||||
- component: {fileID: 997674421}
|
||||
- component: {fileID: 997674422}
|
||||
m_Layer: 7
|
||||
m_Name: Bullet
|
||||
- component: {fileID: 1146100370}
|
||||
- component: {fileID: 1146100369}
|
||||
- component: {fileID: 1146100371}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!212 &997674419
|
||||
--- !u!212 &1146100369
|
||||
SpriteRenderer:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 997674418}
|
||||
m_GameObject: {fileID: 1146100368}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
@@ -408,7 +498,7 @@ SpriteRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_MaskInteraction: 0
|
||||
m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
|
||||
m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
@@ -418,84 +508,85 @@ SpriteRenderer:
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!4 &997674420
|
||||
--- !u!4 &1146100370
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 997674418}
|
||||
m_GameObject: {fileID: 1146100368}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0.12751925, w: 0.9918362}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.05, y: 0.1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_LocalScale: {x: 0.7, y: 0.7, z: 0.7}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children:
|
||||
- {fileID: 8217830}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -14.653}
|
||||
--- !u!114 &997674421
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1146100371
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 997674418}
|
||||
m_GameObject: {fileID: 1146100368}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 80aae26211daf7b4d9f8f603e7c6987f, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 888d5e9b7a6b20447979a287da28b419, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::BulletMovement
|
||||
moveSpeed: 0.05
|
||||
--- !u!61 &997674422
|
||||
BoxCollider2D:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Player
|
||||
bulletPrefab: {fileID: 3217186003837015034, guid: 204cdd5e6f663694d8d6e719543b2018, type: 3}
|
||||
bulletCount: 30
|
||||
--- !u!1 &1777497058
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 997674418}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1777497060}
|
||||
- component: {fileID: 1777497059}
|
||||
m_Layer: 0
|
||||
m_Name: InputManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1777497059
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1777497058}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_ForceSendLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ForceReceiveLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ContactCaptureLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_CallbackLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_CompositeOperation: 0
|
||||
m_CompositeOrder: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 1, y: 1}
|
||||
newSize: {x: 1, y: 1}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_EdgeRadius: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 860109aa4ce233645bc8d7fd7091b26b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::InputManager
|
||||
--- !u!4 &1777497060
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1777497058}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.5963972, y: -0.34278157, z: 0}
|
||||
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!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 519420032}
|
||||
- {fileID: 619394802}
|
||||
- {fileID: 997674420}
|
||||
- {fileID: 1146100370}
|
||||
- {fileID: 1777497060}
|
||||
|
||||
@@ -4,20 +4,23 @@ using UnityEngine;
|
||||
public class BulletMovement : MonoBehaviour
|
||||
{
|
||||
public float moveSpeed = 10;
|
||||
public float lifeTime = 2;
|
||||
private float _currentTime = 0;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
private void OnEnable()
|
||||
{
|
||||
|
||||
_currentTime = lifeTime;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.Translate(Vector2.up * (Time.deltaTime * moveSpeed));
|
||||
_currentTime -= Time.deltaTime;
|
||||
if (_currentTime <= 0)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
31
Assets/Scripts/InputManager.cs
Normal file
31
Assets/Scripts/InputManager.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class InputManager : MonoBehaviour
|
||||
{
|
||||
// 1. 진짜 데이터가 담길 숨겨진 변수
|
||||
private static InputSystem _inputSystem;
|
||||
|
||||
// 2. 외부에서 접근할 프로퍼티
|
||||
public static InputSystem InputSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
// 누군가 InputSystem을 찾았는데 없을 때만 새로 생성
|
||||
_inputSystem ??= new InputSystem();
|
||||
return _inputSystem;
|
||||
}
|
||||
}
|
||||
|
||||
// Start에서는 더 이상 new를 할 필요가 없습니다!
|
||||
// (위의 get에서 자동으로 해주니까요)
|
||||
private void OnEnable()
|
||||
{
|
||||
// 이때 객체가 없으면 자동으로 생성(get 호출)된 후 Enable()이 실행됩니다.
|
||||
InputSystem.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
InputSystem.Disable();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/InputManager.cs.meta
Normal file
2
Assets/Scripts/InputManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 860109aa4ce233645bc8d7fd7091b26b
|
||||
1877
Assets/Scripts/InputSystem.cs
Normal file
1877
Assets/Scripts/InputSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
2
Assets/Scripts/InputSystem.cs.meta
Normal file
2
Assets/Scripts/InputSystem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6eebf4006a33ccf4385b253ac8a23f35
|
||||
23
Assets/Scripts/LivingEntity.cs
Normal file
23
Assets/Scripts/LivingEntity.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class LivingEntity : MonoBehaviour
|
||||
{
|
||||
public float health;
|
||||
public void Damage(float amount)
|
||||
{
|
||||
health -= amount;
|
||||
if (health <= 0)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.gameObject.layer == LayerMask.NameToLayer("Bullet"))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
other.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/LivingEntity.cs.meta
Normal file
2
Assets/Scripts/LivingEntity.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2108c5487af823a49b94fc909c22f92f
|
||||
103
Assets/Scripts/Player.cs
Normal file
103
Assets/Scripts/Player.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
private Camera _camera;
|
||||
private Queue<GameObject> _bulletPool = new Queue<GameObject>();
|
||||
|
||||
public GameObject bulletPrefab;
|
||||
public int bulletCount = 30;
|
||||
|
||||
[Header("연사 설정")]
|
||||
public float fireRate = 0.1f; // 총알 발사 간격 (0.1초마다 1발)
|
||||
private float _fireTimer; // 발사 타이머
|
||||
private bool _isShooting; // 발사 버튼을 누르고 있는지 여부
|
||||
|
||||
void Start()
|
||||
{
|
||||
_camera = Camera.main;
|
||||
|
||||
// 처음 클릭 시 즉시 발사되도록 타이머 초기화
|
||||
_fireTimer = fireRate;
|
||||
|
||||
// 기존의 performed 대신 클릭 시작(started)과 종료(canceled) 이벤트를 연결합니다.
|
||||
InputManager.InputSystem.UI.Click.started += OnShootStarted;
|
||||
InputManager.InputSystem.UI.Click.canceled += OnShootCanceled;
|
||||
|
||||
for (int i = 0; i < bulletCount; i++)
|
||||
{
|
||||
var bullet = Instantiate(bulletPrefab);
|
||||
_bulletPool.Enqueue(bullet);
|
||||
bullet.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 마우스를 클릭하기 시작했을 때
|
||||
private void OnShootStarted(InputAction.CallbackContext obj)
|
||||
{
|
||||
_isShooting = true;
|
||||
}
|
||||
|
||||
// 마우스 클릭을 뗐을 때
|
||||
private void OnShootCanceled(InputAction.CallbackContext obj)
|
||||
{
|
||||
_isShooting = false;
|
||||
}
|
||||
|
||||
// InputAction.CallbackContext 매개변수를 제거하여 Update문에서 호출 가능하게 변경
|
||||
private void Shoot()
|
||||
{
|
||||
var peek = _bulletPool.Dequeue();
|
||||
if (peek.activeInHierarchy)
|
||||
{
|
||||
_bulletPool.Enqueue(peek);
|
||||
peek = Instantiate(bulletPrefab, transform);
|
||||
}
|
||||
peek.transform.rotation = transform.rotation;
|
||||
peek.transform.position = transform.position;
|
||||
peek.SetActive(true);
|
||||
_bulletPool.Enqueue(peek);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_camera is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (InputManager.InputSystem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 캐릭터 회전 처리
|
||||
var mousePos = InputManager.InputSystem.Player.Mouse.ReadValue<Vector2>();
|
||||
var screenToWorldPoint = _camera.ScreenToWorldPoint(mousePos);
|
||||
screenToWorldPoint.z = 0;
|
||||
|
||||
Vector2 direction = screenToWorldPoint - transform.position;
|
||||
var rad2Deg = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
transform.rotation = Quaternion.Euler(0, 0, rad2Deg - 90);
|
||||
|
||||
// 2. 연사 처리 로직
|
||||
_fireTimer += Time.deltaTime; // 타이머는 매 프레임 증가
|
||||
|
||||
if (_isShooting && _fireTimer >= fireRate)
|
||||
{
|
||||
Shoot();
|
||||
_fireTimer = 0f; // 발사 후 타이머 초기화
|
||||
}
|
||||
}
|
||||
|
||||
// 에러나 메모리 누수 방지를 위해 스크립트 파괴 시 이벤트 구독 해제
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (InputManager.InputSystem != null)
|
||||
{
|
||||
InputManager.InputSystem.UI.Click.started -= OnShootStarted;
|
||||
InputManager.InputSystem.UI.Click.canceled -= OnShootCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Player.cs.meta
Normal file
2
Assets/Scripts/Player.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 888d5e9b7a6b20447979a287da28b419
|
||||
Reference in New Issue
Block a user