From f206b5583a66626f8eb83faf77c28c5a8c523b0f Mon Sep 17 00:00:00 2001 From: Ino Date: Mon, 12 Jan 2026 08:53:38 +0900 Subject: [PATCH] =?UTF-8?q?=ED=99=94=EC=82=B4=20=EB=B0=9C=EC=82=AC!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ResWork/Prefab/IngameCharacter.prefab | 2 + Assets/ResWork/Prefab/Play_Ingame.prefab | 40 ++++++++ Assets/Resources.meta | 8 ++ Assets/Resources/Projectile.meta | 8 ++ .../Projectile/Projectile_Arrow.prefab | 93 +++++++++++++++++++ .../Projectile/Projectile_Arrow.prefab.meta | 7 ++ .../Script/InGame/Actor/AimArrowController.cs | 7 ++ .../InGame/{Mgr.meta => Projectile.meta} | 0 Assets/Script/InGame/Projectile/Projectile.cs | 60 ++++++++++++ .../InGame/Projectile/Projectile.cs.meta | 2 + .../Script/InGame/Projectile/ProjectileMgr.cs | 4 + .../InGame/Projectile/ProjectileMgr.cs.meta | 2 + 12 files changed, 233 insertions(+) create mode 100644 Assets/Resources.meta create mode 100644 Assets/Resources/Projectile.meta create mode 100644 Assets/Resources/Projectile/Projectile_Arrow.prefab create mode 100644 Assets/Resources/Projectile/Projectile_Arrow.prefab.meta rename Assets/Script/InGame/{Mgr.meta => Projectile.meta} (100%) create mode 100644 Assets/Script/InGame/Projectile/Projectile.cs create mode 100644 Assets/Script/InGame/Projectile/Projectile.cs.meta create mode 100644 Assets/Script/InGame/Projectile/ProjectileMgr.cs create mode 100644 Assets/Script/InGame/Projectile/ProjectileMgr.cs.meta diff --git a/Assets/ResWork/Prefab/IngameCharacter.prefab b/Assets/ResWork/Prefab/IngameCharacter.prefab index 4501697..46b0d12 100644 --- a/Assets/ResWork/Prefab/IngameCharacter.prefab +++ b/Assets/ResWork/Prefab/IngameCharacter.prefab @@ -626,6 +626,8 @@ MonoBehaviour: m_EditorClassIdentifier: arrow: {fileID: 7666490936302876945} m_AngleSpeed: 5 + projectilePrefab: {fileID: 6506108141890977998, guid: 1432f0b0801152b43a2f86aa07a8fe0b, type: 3} + projectileParent: {fileID: 0} --- !u!223 &5978298300487608438 Canvas: m_ObjectHideFlags: 0 diff --git a/Assets/ResWork/Prefab/Play_Ingame.prefab b/Assets/ResWork/Prefab/Play_Ingame.prefab index bcd526f..400f4bb 100644 --- a/Assets/ResWork/Prefab/Play_Ingame.prefab +++ b/Assets/ResWork/Prefab/Play_Ingame.prefab @@ -4591,6 +4591,7 @@ RectTransform: m_Children: - {fileID: 4111377605235060811} - {fileID: 8406924210966255483} + - {fileID: 5061678075927086196} - {fileID: 4111377606315435504} - {fileID: 4111377605452252100} - {fileID: 4111377605869284182} @@ -6743,6 +6744,41 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!1 &8514717470740185137 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5061678075927086196} + m_Layer: 5 + m_Name: Projectile + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5061678075927086196 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8514717470740185137} + 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: 4111377606588400904} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &8574249056107206163 GameObject: m_ObjectHideFlags: 0 @@ -7133,6 +7169,10 @@ PrefabInstance: propertyPath: m_SortingLayer value: 0 objectReference: {fileID: 0} + - target: {fileID: 3378546718208985526, guid: a095105d5711d2541ba0f518805662c5, type: 3} + propertyPath: projectileParent + value: + objectReference: {fileID: 5061678075927086196} - target: {fileID: 3391742226868558246, guid: a095105d5711d2541ba0f518805662c5, type: 3} propertyPath: m_SortingLayer value: 0 diff --git a/Assets/Resources.meta b/Assets/Resources.meta new file mode 100644 index 0000000..4c56587 --- /dev/null +++ b/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b221ea772a5490468f7bfaea3124d52 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Projectile.meta b/Assets/Resources/Projectile.meta new file mode 100644 index 0000000..9a9b760 --- /dev/null +++ b/Assets/Resources/Projectile.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82b3abff7d5939a4787eb956df44a82c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Projectile/Projectile_Arrow.prefab b/Assets/Resources/Projectile/Projectile_Arrow.prefab new file mode 100644 index 0000000..31dacfe --- /dev/null +++ b/Assets/Resources/Projectile/Projectile_Arrow.prefab @@ -0,0 +1,93 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6506108141890977998 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1218441243008823837} + - component: {fileID: 6182406677487406681} + - component: {fileID: 6535598282516247635} + - component: {fileID: 5283165188844738288} + m_Layer: 0 + m_Name: Projectile_Arrow + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1218441243008823837 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6506108141890977998} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2.5, y: 3, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 54, y: 64} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6182406677487406681 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6506108141890977998} + m_CullTransparentMesh: 1 +--- !u!114 &6535598282516247635 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6506108141890977998} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 9dea6512a45784ff7b2a5bbdfa996d16, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &5283165188844738288 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6506108141890977998} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ccfe1723f3c6dc74787642c082b79437, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 2 + maxBounce: 3 + radius: 0.1 diff --git a/Assets/Resources/Projectile/Projectile_Arrow.prefab.meta b/Assets/Resources/Projectile/Projectile_Arrow.prefab.meta new file mode 100644 index 0000000..5f72c06 --- /dev/null +++ b/Assets/Resources/Projectile/Projectile_Arrow.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1432f0b0801152b43a2f86aa07a8fe0b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Script/InGame/Actor/AimArrowController.cs b/Assets/Script/InGame/Actor/AimArrowController.cs index a85db38..dfaf89b 100644 --- a/Assets/Script/InGame/Actor/AimArrowController.cs +++ b/Assets/Script/InGame/Actor/AimArrowController.cs @@ -5,6 +5,8 @@ public class AimArrowController : MonoBehaviour { public Image arrow; public float m_AngleSpeed = 1.5f; + public GameObject projectilePrefab; + public Transform projectileParent; Vector2 startPos; bool isAiming; @@ -31,6 +33,11 @@ public class AimArrowController : MonoBehaviour { arrow.enabled = false; isAiming = false; + + var proj = DSUtil.Get_Clone(projectilePrefab, projectileParent); + proj.transform.position = arrow.transform.position; + proj.transform.rotation = arrow.transform.rotation; + proj.Set(); } void UpdateArrow(Vector2 currentPos) diff --git a/Assets/Script/InGame/Mgr.meta b/Assets/Script/InGame/Projectile.meta similarity index 100% rename from Assets/Script/InGame/Mgr.meta rename to Assets/Script/InGame/Projectile.meta diff --git a/Assets/Script/InGame/Projectile/Projectile.cs b/Assets/Script/InGame/Projectile/Projectile.cs new file mode 100644 index 0000000..3c38f48 --- /dev/null +++ b/Assets/Script/InGame/Projectile/Projectile.cs @@ -0,0 +1,60 @@ +using UnityEngine; + +public class Projectile : MonoBehaviour +{ + public float speed = 12f; + public int maxBounce = 3; + public float radius = 0.1f; // 충돌 보정용 + + Vector2 dir; + int bounceCount; + + public void Set() + { + dir = transform.up.normalized; + bounceCount = maxBounce; + } + + void Update() + { + float moveDist = speed * Time.deltaTime; + + // 🔍 이동 방향으로 Raycast + RaycastHit2D hit = Physics2D.CircleCast( + transform.position, + radius, + dir, + moveDist + ); + + if (hit.collider != null) + { + // 충돌 지점으로 이동 + transform.position = hit.point + hit.normal * radius; + + Bounce(hit.normal); + } + else + { + transform.position += (Vector3)(dir * moveDist); + } + } + + void Bounce(Vector2 normal) + { + bounceCount--; + + if (bounceCount < 0) + { + Destroy(gameObject); + return; + } + + // 🔥 반사 방향 계산 + dir = Vector2.Reflect(dir, normal).normalized; + + // 반사 후 방향에 맞게 회전 + float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90f; + transform.rotation = Quaternion.Euler(0, 0, angle); + } +} \ No newline at end of file diff --git a/Assets/Script/InGame/Projectile/Projectile.cs.meta b/Assets/Script/InGame/Projectile/Projectile.cs.meta new file mode 100644 index 0000000..988bde8 --- /dev/null +++ b/Assets/Script/InGame/Projectile/Projectile.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ccfe1723f3c6dc74787642c082b79437 \ No newline at end of file diff --git a/Assets/Script/InGame/Projectile/ProjectileMgr.cs b/Assets/Script/InGame/Projectile/ProjectileMgr.cs new file mode 100644 index 0000000..9e11c23 --- /dev/null +++ b/Assets/Script/InGame/Projectile/ProjectileMgr.cs @@ -0,0 +1,4 @@ +public class ProjectileMgr : MonoBehaviourSingletonTemplate +{ + +} \ No newline at end of file diff --git a/Assets/Script/InGame/Projectile/ProjectileMgr.cs.meta b/Assets/Script/InGame/Projectile/ProjectileMgr.cs.meta new file mode 100644 index 0000000..6fe68b3 --- /dev/null +++ b/Assets/Script/InGame/Projectile/ProjectileMgr.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ab49994372de82649878bfdb8faf3b90 \ No newline at end of file