- Home /
Cutscene Segments
I'd imagine this is way easier than I think, but I'm curious as to how I would go about waiting for a part of a cutscene to finish, along with pressing a button to continue, would move onto the next part. I've figured it out, but I don't think it's really optimized as best as it could be. Here's my theoretical script.
var Continue1 : boolean = false;
var Continue2 : boolean = false;
function OnTriggerEnter(hit : Collider){
if(hit.gameObject.tag == "Player"){
Part1();
}
}
function Update(){
if(Continue1 && Input.GetButtonUp("A")){
Continue1 = false;
Part2();
}
if(Continue2 && Input.GetButtonUp("A")){
Continue2 = false;
Part3();
}
}
function Part1(){
GameControl.inCutscene = true;
//Do Stuff
yield WaitForSeconds(5);
Continue1 = true;
yield WaitForSeconds(5);
if(Continue1){
Continue1 = false;
Part2();
}
}
function Part2(){
//Do Stuff
yield WaitForSeconds(5);
Continue2 = true;
yield WaitForSeconds(5);
if(Continue2){
Continue2 = false;
Part3();
}
}
function Part3(){
//Do Stuff
yield WaitForSeconds(5);
GameControl.inCutscene = false;
}
Essentially, I would have each Part spawn some text and pressing A would close it and move on to the next piece of text. I just wanted to know if this is the best approach or if I can somehow link the Functions to an integer and have each part add 1 to the integer and make the function corresponding to the integer start. Example:
Integer = 1;
Part(Integer);
Something like that to start Part1, sorry if I'm confusing, I'll elaborate more if needed.
Answer by unluckyBastard · Aug 17, 2011 at 11:34 PM
var Continue : boolean = false;
function Awake(){
Continue = false;
}
function OnTriggerEnter(hit : Collider){
if(hit.gameObject.tag == "Player"){
Part(1, 5);
}
}
function Update(){
if(!Continue && Input.GetButtonUp("A")){
Continue = true;
Part(1 //which part,5 //how long is it (seconds));
}
}
function Part(a : int, b : int){
GameControl.inCutscene = true;
if(a == 1){
//cutscene one
}
else if(a == 2){
//cutscene two
}
etc...
//Do Stuff
yield WaitForSeconds(b);
Continue = true;
yield WaitForSeconds(b);
Continue = false;
}
^ that is a simpler way, because it can be accessed easily from other scripts. and to make a cutscene you would have to make the animations using the built-in animation manager (CTRL+6) and disable all player controls until the cutscene is over. Hope this helped.
It helped a little, but I'm still confused as to how I would go about telling which Function to execute based on an int. I'm accessing these cutscenes by walking into a scripted collider.