화살 발사!

This commit is contained in:
Ino 2026-01-12 08:53:38 +09:00
parent b50884cd95
commit f206b5583a
12 changed files with 233 additions and 0 deletions

View File

@ -626,6 +626,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
arrow: {fileID: 7666490936302876945} arrow: {fileID: 7666490936302876945}
m_AngleSpeed: 5 m_AngleSpeed: 5
projectilePrefab: {fileID: 6506108141890977998, guid: 1432f0b0801152b43a2f86aa07a8fe0b, type: 3}
projectileParent: {fileID: 0}
--- !u!223 &5978298300487608438 --- !u!223 &5978298300487608438
Canvas: Canvas:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -4591,6 +4591,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 4111377605235060811} - {fileID: 4111377605235060811}
- {fileID: 8406924210966255483} - {fileID: 8406924210966255483}
- {fileID: 5061678075927086196}
- {fileID: 4111377606315435504} - {fileID: 4111377606315435504}
- {fileID: 4111377605452252100} - {fileID: 4111377605452252100}
- {fileID: 4111377605869284182} - {fileID: 4111377605869284182}
@ -6743,6 +6744,41 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 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 --- !u!1 &8574249056107206163
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -7133,6 +7169,10 @@ PrefabInstance:
propertyPath: m_SortingLayer propertyPath: m_SortingLayer
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3378546718208985526, guid: a095105d5711d2541ba0f518805662c5, type: 3}
propertyPath: projectileParent
value:
objectReference: {fileID: 5061678075927086196}
- target: {fileID: 3391742226868558246, guid: a095105d5711d2541ba0f518805662c5, type: 3} - target: {fileID: 3391742226868558246, guid: a095105d5711d2541ba0f518805662c5, type: 3}
propertyPath: m_SortingLayer propertyPath: m_SortingLayer
value: 0 value: 0

8
Assets/Resources.meta Normal file
View File

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

View File

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

View File

@ -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

View File

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

View File

@ -5,6 +5,8 @@ public class AimArrowController : MonoBehaviour
{ {
public Image arrow; public Image arrow;
public float m_AngleSpeed = 1.5f; public float m_AngleSpeed = 1.5f;
public GameObject projectilePrefab;
public Transform projectileParent;
Vector2 startPos; Vector2 startPos;
bool isAiming; bool isAiming;
@ -31,6 +33,11 @@ public class AimArrowController : MonoBehaviour
{ {
arrow.enabled = false; arrow.enabled = false;
isAiming = false; isAiming = false;
var proj = DSUtil.Get_Clone<Projectile>(projectilePrefab, projectileParent);
proj.transform.position = arrow.transform.position;
proj.transform.rotation = arrow.transform.rotation;
proj.Set();
} }
void UpdateArrow(Vector2 currentPos) void UpdateArrow(Vector2 currentPos)

View File

@ -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);
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ccfe1723f3c6dc74787642c082b79437

View File

@ -0,0 +1,4 @@
public class ProjectileMgr : MonoBehaviourSingletonTemplate<ProjectileMgr>
{
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ab49994372de82649878bfdb8faf3b90