feat : 매직미사일 기본 동작 구현
- 플레이어가 움직이는 방향을 참고하여 예측샷 발사
This commit is contained in:
parent
393b538920
commit
50e5b8db98
8
Assets/JYY/Prefabs/Bullets.meta
Normal file
8
Assets/JYY/Prefabs/Bullets.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37e30a87d9c904c898232118c82b5fbc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/JYY/Prefabs/Bullets/Dummy Magic Missaile.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/JYY/Prefabs/Bullets/Dummy Magic Missaile.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c16b44c8736e4007ad5f0733ce433e1
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/JYY/Scenes/MonsterTest.unity
(Stored with Git LFS)
BIN
Assets/JYY/Scenes/MonsterTest.unity
(Stored with Git LFS)
Binary file not shown.
@ -57,6 +57,8 @@ public class BulletBase : MonoBehaviour
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
// TODO: 주인공 캐릭터를 찾는 로직 추가 필요
|
||||
// 주인공 스크립트를 찾아 처리할 것.
|
||||
var character = other.GetComponent<CharacterBase>();
|
||||
if (character != null)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MagicMissaile : BulletBase
|
||||
public class MagicMissile : BulletBase
|
||||
{
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ public class CasterDemonController : EnemyController
|
||||
private bool _isFirstNoPath = true;
|
||||
|
||||
[SerializeField] private Transform teleportTransform;
|
||||
[SerializeField] private Transform bulletShotPosition;
|
||||
[SerializeField] private GameObject magicMissilePrefab;
|
||||
|
||||
public override void BattleSequence()
|
||||
@ -20,9 +21,8 @@ public class CasterDemonController : EnemyController
|
||||
|
||||
// TODO : 배틀 중일 때 루프
|
||||
Debug.Log("## 몬스터의 교전 행동 루프");
|
||||
StartCoroutine(ShotMagicMissile());
|
||||
|
||||
// 전투 행동이 끝남
|
||||
_doneBattleSequence = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,15 +39,54 @@ public class CasterDemonController : EnemyController
|
||||
}
|
||||
}
|
||||
|
||||
private void ShotMagicMissile()
|
||||
private IEnumerator ShotMagicMissile()
|
||||
{
|
||||
this.transform.LookAt(TraceTargetTransform.position);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
// 1. 기본 위치
|
||||
Vector3 basePos = TraceTargetTransform.position;
|
||||
Vector3 aimPosition = basePos;
|
||||
|
||||
// 2. 플레이어 Rigidbody로 속도 얻기
|
||||
if (TraceTargetTransform.TryGetComponent<Rigidbody>(out var rb))
|
||||
{
|
||||
// 아주 짧은 시간만 예측
|
||||
float predictionTime = 0.3f;
|
||||
aimPosition += rb.velocity * predictionTime;
|
||||
}
|
||||
|
||||
// 높이는 변경할 필요 없음
|
||||
float fixedY = bulletShotPosition.position.y;
|
||||
aimPosition.y = fixedY;
|
||||
|
||||
// 3. 그 위치를 바라보고
|
||||
transform.LookAt(aimPosition);
|
||||
|
||||
// 4. 미사일 생성 및 초기화
|
||||
var missile = Instantiate(
|
||||
magicMissilePrefab,
|
||||
bulletShotPosition.position,
|
||||
transform.rotation
|
||||
);
|
||||
missile.GetComponent<MagicMissile>()
|
||||
.Initialize(new BulletData(aimPosition, 5f, 10f, 5f));
|
||||
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
}
|
||||
|
||||
// 짧은 텀 후 끝내기
|
||||
yield return new WaitForSeconds(1f);
|
||||
_doneBattleSequence = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Teleport()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user