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.
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.
– Xatoku