using UnityEngine; public class StairWarp : MonoBehaviour { [Header("Standard Warps")] public Transform[] randomRooms; [Header("Special Traps")] public TVRoomTrap tvTrapScript; // <--- ASSIGN THIS IN INSPECTOR [Range(0, 100)] public float trapChance = 10f; // 10% chance for the TV Trap [Header("General Settings")] [Range(0, 100)] public float warpChance = 30f; public AudioSource audioSource; public AudioClip warpWhooshSound; private bool hasTriggered = false; public void WarpPlayer(GameObject player) { // 1. Check for SPECIAL TRAP first // If we have the script assigned and roll the dice successfully... if (tvTrapScript != null && Random.Range(0, 100) < trapChance) { Debug.Log("TRIGGERING TV TRAP!"); tvTrapScript.TriggerTrap(player); return; // Exit function, do not do normal warp } // 2. Normal Room Warp (Your existing logic) if (randomRooms.Length == 0) return; Transform target = randomRooms[Random.Range(0, randomRooms.Length)]; CharacterController cc = player.GetComponent(); if (cc != null) cc.enabled = false; player.transform.position = target.position; player.transform.rotation = target.rotation; if (cc != null) cc.enabled = true; if (audioSource != null && warpWhooshSound != null) audioSource.PlayOneShot(warpWhooshSound); Debug.Log("Player warped to: " + target.name); } // (Keep your OnTriggerEnter / OnTriggerExit logic the same, // just make sure OnTriggerEnter calls WarpPlayer(other.gameObject)) void OnTriggerEnter(Collider other) { if (other.CompareTag("Player") && !hasTriggered) { hasTriggered = true; if (Random.Range(0, 100) < warpChance) { WarpPlayer(other.gameObject); } } } void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) hasTriggered = false; } }