diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab index 1a0f4e6..cb3fbc1 100644 --- a/Assets/Prefabs/Enemy.prefab +++ b/Assets/Prefabs/Enemy.prefab @@ -151,8 +151,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1c203980d40e2bf4392783aade147dca, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::EnemyAttack - damage: 20 - attackCooldown: 1 + damage: 1 + attackCooldown: 5 --- !u!114 &7188026176818599596 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/SampleScene/NavMesh-Ground.asset b/Assets/Scenes/SampleScene/NavMesh-Ground.asset index 35eef06..f55fad9 100644 Binary files a/Assets/Scenes/SampleScene/NavMesh-Ground.asset and b/Assets/Scenes/SampleScene/NavMesh-Ground.asset differ diff --git a/Assets/Scripts/GameBase/Portal.cs b/Assets/Scripts/GameBase/Portal.cs new file mode 100644 index 0000000..2753cb2 --- /dev/null +++ b/Assets/Scripts/GameBase/Portal.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +public class Portal : MonoBehaviour +{ + [SerializeField] private Transform destination; // 순간이동할 목적지 (반대편 포탈의 위치) + [SerializeField] private float cooldown = 1f; // 연속 이동 방지 쿨타임 + private float _lastTeleportTime; + + private void OnTriggerEnter(Collider other) + { + // 플레이어 태그 확인 및 쿨타임 체크 + if (other.CompareTag("Player") && Time.time > _lastTeleportTime + cooldown) + { + // 상대방 포탈의 쿨타임도 같이 설정해야 무한 루프를 방지함 + Portal destPortal = destination.GetComponent(); + if (destPortal != null) destPortal._lastTeleportTime = Time.time; + + _lastTeleportTime = Time.time; + + // 플레이어 위치 이동 + // CharacterController나 Rigidbody를 사용 중이라면 이동 방식에 주의 + other.transform.position = destination.position; + + Debug.Log("Teleported to " + destination.name); + } + } +} \ No newline at end of file