- Home /
How to rig a cutscene Camera back to it's original place
I have set a condition to where if an certain event is triggered an object will fall. The camera switches to the cutscene camera no problem, but it won't switch back afterward.
var mainCamera : GameObject; var cCamera : GameObject;
function Update () {
if (Sentry_Damage.Cardrelease == true){ mainCamera.GetComponent(AudioListener).enabled = false; cCamera.active = true; cCamera.GetComponent(AudioListener).enabled = true;
var RB = gameObject.AddComponent(Rigidbody); RB.freezeRotation = true;
cCamera.active = false; // this lets the NearCamera get the screen all to itself. cCamera.GetComponent(AudioListener).enabled = false; mainCamera.active = true; mainCamera.GetComponent(AudioListener).enabled = true;
} else { return; } }
Does anyone know what the problem is or a solution?
Answer by Design3.com · Apr 10, 2010 at 12:14 AM
I'm not sure exactly what you need to do, but I assume you're cutting to cCamera momentarily, then reverting back to the mainCamera? Because this is all in the Update function, the cameras will be perpetually switching back and forth so long as Sentry_Damage.Cardrelease == true. I would use a Coroutine and put a yield in between camera switches. Something like:
var isCutscene : boolean = false;
function Update() { if (Sentry_Damage.Cardrelease == true && !isCutscene) { isCutscene = true; CutScene(); } } function CutScene() { mainCamera.GetComponent(AudioListener).enabled = false; cCamera.active = true; cCamera.GetComponent(AudioListener).enabled = true;
var RB = gameObject.AddComponent(Rigidbody); RB.freezeRotation = true;
yield WaitForSeconds(0.5);
cCamera.active = false; // this lets the NearCamera get the screen all to itself. cCamera.GetComponent(AudioListener).enabled = false; mainCamera.active = true; mainCamera.GetComponent(AudioListener).enabled = true; }
Your answer
Follow this Question
Related Questions
Use lookAt and transform.translate at the same time 1 Answer
How do you force a player to look at something? 4 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Using switch/case with Colliders and Cameras 3 Answers
Jittering Camera 3D ,Jittery 3D camera using a LookAt() on an object 0 Answers