Merge branch 'master' of github.com:WillJeynes/Brackeys2026-2
This commit is contained in:
@@ -172,54 +172,68 @@ public class CameraController : MonoBehaviour
|
||||
{
|
||||
isSequencePlaying = true;
|
||||
RemoveHighlight();
|
||||
|
||||
// 1. TRIPWIRE: Check if the slots are empty!
|
||||
if (activeDoor.type == "DEATH")
|
||||
{
|
||||
if (activeDoor.deathCamera == null) Debug.LogError("🚨 ERROR: This is a DEATH door, but the Death Camera slot is empty in the Prefab Inspector!");
|
||||
if (activeDoor.deathSplineDolly == null) Debug.LogError("🚨 ERROR: This is a DEATH door, but the Death Spline Dolly slot is empty in the Prefab Inspector!");
|
||||
}
|
||||
|
||||
// 1. Determine which camera and track to use based on the door type
|
||||
bool isDeathDoor = activeDoor.type == "DEATH" && activeDoor.deathCamera != null;
|
||||
// 2. Determine which camera to use
|
||||
bool isDeathDoor = activeDoor.type == "DEATH" && activeDoor.deathCamera != null && activeDoor.deathSplineDolly != null;
|
||||
|
||||
CinemachineCamera activeCam = isDeathDoor ? activeDoor.deathCamera : activeDoor.doorCamera;
|
||||
CinemachineSplineDolly activeDolly = isDeathDoor ? activeDoor.deathSplineDolly : activeDoor.doorSplineDolly;
|
||||
|
||||
// 2. Reset the chosen track and boost its priority
|
||||
// 3. TRIPWIRE: Tell us which camera was actually chosen
|
||||
Debug.Log($"🎯 Door clicked! Type is: '{activeDoor.type}'. Script is using track: '{activeCam.gameObject.name}'");
|
||||
|
||||
activeDolly.CameraPosition = 0f;
|
||||
activeCam.Priority = 30;
|
||||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
// 3. Push the camera (You might want to speed this up for the death drop!)
|
||||
float pushSpeed = 0.5f;
|
||||
// --- DISTANCE MOVEMENT FIX ---
|
||||
// Using real metres now! 5f means 5 metres per second. Adjust this if it falls too slowly!
|
||||
float pushSpeed = 5f;
|
||||
float previousPosition = -1f;
|
||||
|
||||
while (activeDoor != null && activeDolly != null && activeDolly.CameraPosition < 1f)
|
||||
while (activeDoor != null && activeDolly != null && activeDolly.CameraPosition > previousPosition)
|
||||
{
|
||||
previousPosition = activeDolly.CameraPosition;
|
||||
activeDolly.CameraPosition += pushSpeed * Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
// ------------------------------
|
||||
|
||||
string doorType = activeDoor != null ? activeDoor.type : "";
|
||||
|
||||
// 4. Safely drop the camera's priority
|
||||
if (activeCam != null)
|
||||
{
|
||||
activeCam.Priority = inactivePriority;
|
||||
}
|
||||
|
||||
// 5. Trigger the appropriate level logic
|
||||
// --- PRIORITY FIX ---
|
||||
if (doorType == "LIFE")
|
||||
{
|
||||
// Drop priority ONLY for the safe door, so the Intro Sequence can take over
|
||||
if (activeCam != null) activeCam.Priority = inactivePriority;
|
||||
|
||||
Debug.Log("Safe door chosen! Advancing to the next level.");
|
||||
GlobalStateManager.Instance.SetLevelCompleted();
|
||||
yield return StartCoroutine(IntroSequenceRoutine());
|
||||
}
|
||||
else if (doorType == "DEATH")
|
||||
{
|
||||
Debug.Log("Wrong door! Teleporting back to start.");
|
||||
// Insert your death/teleport logic here
|
||||
Debug.Log("Wrong door! Player died.");
|
||||
|
||||
// We intentionally DO NOT drop the priority here.
|
||||
// The camera stays locked at Priority 30, trapping the player's view at the bottom of the pit!
|
||||
isSequencePlaying = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activeCam != null) activeCam.Priority = inactivePriority;
|
||||
Debug.LogWarning($"Door type '{doorType}' is not recognised.");
|
||||
isSequencePlaying = false;
|
||||
ReturnToMainCamera();
|
||||
}
|
||||
|
||||
// 6. Play the intro sweep for the newly generated room or restart
|
||||
yield return StartCoroutine(IntroSequenceRoutine());
|
||||
}
|
||||
|
||||
private void HandleEdgeNudge()
|
||||
|
||||
Reference in New Issue
Block a user