Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Xatoku · Aug 17, 2011 at 11:14 PM · coroutinefunctionintegercutscene

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Xatoku · Aug 18, 2011 at 12:14 AM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

calling c# function from a js file.. 1 Answer

Coroutine will be executed only once, why? 1 Answer

My function isn't ending but is being repeatedly being called from the update function 1 Answer

private Vector3 function? 2 Answers

Accessing functions on external JS in the same object 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges