Enemy의 이동 및 공격 로직 개선
포탈 추가
This commit is contained in:
@@ -11,17 +11,22 @@ public class Portal : MonoBehaviour
|
||||
// 플레이어 태그 확인 및 쿨타임 체크
|
||||
if (other.CompareTag("Player") && Time.time > _lastTeleportTime + cooldown)
|
||||
{
|
||||
// 상대방 포탈의 쿨타임도 같이 설정해야 무한 루프를 방지함
|
||||
CharacterController cc = other.GetComponent<CharacterController>();
|
||||
|
||||
// 1. 상대방 포탈 쿨타임 설정
|
||||
Portal destPortal = destination.GetComponent<Portal>();
|
||||
if (destPortal != null) destPortal._lastTeleportTime = Time.time;
|
||||
|
||||
_lastTeleportTime = Time.time;
|
||||
|
||||
// 플레이어 위치 이동
|
||||
// CharacterController나 Rigidbody를 사용 중이라면 이동 방식에 주의
|
||||
other.transform.position = destination.position;
|
||||
// 2. CharacterController 잠시 끄기 (중요!)
|
||||
if (cc != null) cc.enabled = false;
|
||||
|
||||
// 3. 위치 이동
|
||||
other.transform.position = destination.position;
|
||||
Debug.Log("Teleported to " + destination.name);
|
||||
|
||||
// 4. 다시 켜기
|
||||
if (cc != null) cc.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user