Trouble Triggering Realtime Cutscene

Hey everyone! I am very new to coding and unity overall, so please forgive my overall ignorance in this area; I am learning though!

Ok, so I am trying to have a realtime cutscene happen when the player gets to a certain spot on the level. Right now, I have it set up to switch to a different camera other than the main camera on my FPSController for the animation. The code looks like this:

var CutCam : Camera;
var MainCamera : Camera;
var camClip : AnimationClip;

function OnTriggerEnter(col : Collider) {
	
	if(col.gameObject.tag=="Player"){
	
		GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = false;
		GameObject.Find("Graphics").GetComponent(MeshRenderer).enabled = false;
		CutCam.camera.enabled = true;
		MainCamera.camera.enabled = false;
		ladder.animation.Play();

	}	
}

However, when I play the game, it only shows the animation of the CutCam looking up the ladder. It doesn’t start on the FPS if this script is active anywhere.

I have this code placed on a box collider at the point I want the animation to start playing in the level.

Thanks in advance for anything you can do to help!

2 Answers

2

Hi there, I’m in the “same boat” too. But, as I can see, You’re probably trying to use the couple of script called “CameraSwitch” and “BoxPhysics”, picked up by some good tutorial on youtube, right?
Well, if you look at the code, you can see there are 2 script: one on the camera (the one that switch between cameras) and the BoxPhysics put on the cube. At the beginning of CameraSwitch script, you can see what happens “on Start”: there it sets the second camera as the beginning camera. You need to change, to let start your scene with the FPS camera.
After that, as I understood so far, you need to “link” the two scripta, making function that call each other when something happens (the cubes explode, like in the example).
I hope I can help to walk around this first problem :slight_smile:

Hey everyone! Thank you for your responses! I did end up getting it to work! I did as Zongo79 said and moved my camera enabling and disabling scripts into a Start function. And thanks for mentioning Movie Textures as I have just started to play around with those also!

If 'Zongo79' answered your question, please click on the checkmark to the left of the question to close it out. Thanks.

Did you try to use movietexture?

It's pretty helpfull. Just render a cutscene in sony vegas or movie maker or something and inport as movietexture. Note: It requires unity pro

It requires pro. maybe he does not have it.

I'm sorry guys but - even if Movie texture is very cool - I don't believe that you found the focus of the matter. I think that the solution for Opendoors would be to put on "function Start ()" something that could set the first camera, for instance: <pre> function Start() { CutCam.camera.enabled = false; MainCamera.camera.enabled = true; } </pre> In this way you force to start the scene with your main cam. Hope this could help! (Thanks for making me know this Movie Texture command :) )