[fix] 의도되지 않은 타이밍에도 텔레포트가 실행되는 문제 수정
- 텔레포트를 사용할 수 있는 빈도 조정 - 텔레포트 처리 로직 정리 Work in JIRA ISSUE DEG-100 DEG-109 #Close
This commit is contained in:
parent
71a904e57e
commit
c2732adc76
BIN
Assets/JYY/Scenes/MonsterTest.unity
(Stored with Git LFS)
BIN
Assets/JYY/Scenes/MonsterTest.unity
(Stored with Git LFS)
Binary file not shown.
@ -16,12 +16,12 @@ public class CasterDemonController : EnemyController
|
|||||||
[SerializeField] private Transform bulletShotPosition;
|
[SerializeField] private Transform bulletShotPosition;
|
||||||
[SerializeField] private GameObject magicMissilePrefab;
|
[SerializeField] private GameObject magicMissilePrefab;
|
||||||
[SerializeField] private GameObject teleportEffectPrefab;
|
[SerializeField] private GameObject teleportEffectPrefab;
|
||||||
[SerializeField] private float teleportDistance = 4f; // 플레이어 뒤로 떨어질 거리
|
|
||||||
|
|
||||||
|
private float _teleportDistance = 4f; // 플레이어 뒤로 떨어질 거리
|
||||||
|
|
||||||
// 텔레포트 쿨타임
|
// 텔레포트 쿨타임
|
||||||
private float _teleportTimer = 0;
|
private float _teleportTimer = 0;
|
||||||
private const float TeleportThresholdTime = 3.5f;
|
private const float TeleportThresholdTime = 20f;
|
||||||
|
|
||||||
private bool CanTeleport {
|
private bool CanTeleport {
|
||||||
get
|
get
|
||||||
@ -82,12 +82,16 @@ public class CasterDemonController : EnemyController
|
|||||||
SetSequence(ShotMagicMissile());
|
SetSequence(ShotMagicMissile());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnCannotFleeBehaviour()
|
public override void OnCannotFleeBehaviour(Action action)
|
||||||
{
|
{
|
||||||
if(CanTeleport)
|
if (CanTeleport)
|
||||||
SetSequence(Teleport());
|
{
|
||||||
|
action();
|
||||||
|
Teleport();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator ShotMagicMissile()
|
private IEnumerator ShotMagicMissile()
|
||||||
@ -137,7 +141,7 @@ public class CasterDemonController : EnemyController
|
|||||||
return aimPosition;
|
return aimPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator Teleport()
|
private void Teleport()
|
||||||
{
|
{
|
||||||
Vector3 startPos = transform.position;
|
Vector3 startPos = transform.position;
|
||||||
if (teleportEffectPrefab != null)
|
if (teleportEffectPrefab != null)
|
||||||
@ -146,7 +150,7 @@ public class CasterDemonController : EnemyController
|
|||||||
// 플레이어 뒤쪽 위치 계산
|
// 플레이어 뒤쪽 위치 계산
|
||||||
Vector3 playerPos = TraceTargetTransform.position;
|
Vector3 playerPos = TraceTargetTransform.position;
|
||||||
Vector3 behindDir = -TraceTargetTransform.forward;
|
Vector3 behindDir = -TraceTargetTransform.forward;
|
||||||
Vector3 targetPos = playerPos + behindDir.normalized * teleportDistance;
|
Vector3 targetPos = playerPos + behindDir.normalized * _teleportDistance;
|
||||||
|
|
||||||
// NavMesh 유효 위치 확인
|
// NavMesh 유효 위치 확인
|
||||||
Vector3 finalPos = targetPos;
|
Vector3 finalPos = targetPos;
|
||||||
@ -155,15 +159,11 @@ public class CasterDemonController : EnemyController
|
|||||||
finalPos = hit.position;
|
finalPos = hit.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new WaitForSeconds(0.3f);
|
|
||||||
|
|
||||||
// 텔레포트 실행
|
// 텔레포트 실행
|
||||||
Agent.Warp(finalPos);
|
Agent.Warp(finalPos);
|
||||||
|
|
||||||
if (teleportEffectPrefab != null)
|
if (teleportEffectPrefab != null)
|
||||||
Instantiate(teleportEffectPrefab, finalPos, Quaternion.identity);
|
Instantiate(teleportEffectPrefab, finalPos, Quaternion.identity);
|
||||||
|
|
||||||
yield return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSequence(IEnumerator newSequence)
|
private void SetSequence(IEnumerator newSequence)
|
||||||
|
@ -122,6 +122,10 @@ public abstract class EnemyController : CharacterBase
|
|||||||
{
|
{
|
||||||
Debug.LogWarning("OnCannotFleeBehaviour가 구현되지 않음 : OnCannotFleeBehaviour() 오버라이드하여 구현하십시오.");
|
Debug.LogWarning("OnCannotFleeBehaviour가 구현되지 않음 : OnCannotFleeBehaviour() 오버라이드하여 구현하십시오.");
|
||||||
}
|
}
|
||||||
|
public virtual void OnCannotFleeBehaviour(Action action)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("OnCannotFleeBehaviour가 구현되지 않음 : OnCannotFleeBehaviour() 오버라이드하여 구현하십시오.");
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.AI;
|
using UnityEngine.AI;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
public class EnemyStateFlee :IEnemyState
|
public class EnemyStateFlee :IEnemyState
|
||||||
{
|
{
|
||||||
@ -107,11 +109,9 @@ public class EnemyStateFlee :IEnemyState
|
|||||||
{
|
{
|
||||||
if (_stuckCount >= 4)
|
if (_stuckCount >= 4)
|
||||||
{
|
{
|
||||||
_enemyController.OnCannotFleeBehaviour();
|
_enemyController.OnCannotFleeBehaviour(() => { _stuckCount = 0;});
|
||||||
_stuckCount = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_stuckCount++;
|
|
||||||
// 무작위 도망 지점 샘플링 시도
|
// 무작위 도망 지점 샘플링 시도
|
||||||
Vector3 randomDirection = Random.insideUnitSphere * (_fleeDistance * 2);
|
Vector3 randomDirection = Random.insideUnitSphere * (_fleeDistance * 2);
|
||||||
randomDirection += _playerTransform.position;
|
randomDirection += _playerTransform.position;
|
||||||
@ -120,16 +120,10 @@ public class EnemyStateFlee :IEnemyState
|
|||||||
{
|
{
|
||||||
// 샘플링에 성공했으면 일단 그 위치로 가 보도록 세팅
|
// 샘플링에 성공했으면 일단 그 위치로 가 보도록 세팅
|
||||||
Debug.Log("## 일단 가봄");
|
Debug.Log("## 일단 가봄");
|
||||||
|
_stuckCount++;
|
||||||
_enemyController.Agent.SetDestination(hit.position);
|
_enemyController.Agent.SetDestination(hit.position);
|
||||||
// _enemyController.OnCannotFleeBehaviour();
|
// _enemyController.OnCannotFleeBehaviour();
|
||||||
}
|
}
|
||||||
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // 대체 경로도 찾을 수 없는 경우
|
|
||||||
// Debug.Log("## 대체 경로도 못찾음");
|
|
||||||
// _enemyController.OnCannotFleeBehaviour();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user