Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 orphea · Dec 05, 2010 at 07:37 PM · coroutinecutsceneinternalcs0119cs1624

Problem creating a cutscene event in c#

Hi,

I am trying to trigger a cutscene in c# using a condition referring to another c# script (QuestIt addon - Quest Manager script (QM in the below script)). I need the cutscene when a quest is done. I know my condition is good since I use it for a final cutscene in another level and it works perfectly. But I need to use a coroutine for the internal cutscenes since once my condition is true, the cutscene will always loop and I don't want this.

I don't understand the c# syntax very well yet. I use it only because I don't know how to use the same condition in Javascript.

I would really appreciate your help.

I get this error: Assets/Script/cutscenes_trigger.cs(21,14): error CS1624: The body of cutscenes_trigger.CutScene()' cannot be an iterator block becausevoid' is not an iterator interface type

Here is the script I am using:

using UnityEngine; using System.Collections;

public class cutscenes_trigger : MonoBehaviour { public GameObject cuts_cam; public GameObject main_cam; public int questID; private bool isCutscene = false;

 void Update() 
     {

         if(QM.Ins.GetQuestStatus(questID) == questConditions.DONE && !isCutscene)
         {
             isCutscene = true;
             CutScene();
         }
     }

 void CutScene() 
     {

         cuts_cam.active(true);
         main_cam.active(false);

         yield return new WaitForSeconds(4);


         cuts_cam.active(false); 
         main_cam.active(true);

     }

}

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Maarten · Dec 05, 2010 at 07:48 PM

Make the void a IEnumerator. So it changes from:

void CutScene()

to:

IEnumerator CutScene()
Comment
Add comment · 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
0

Answer by orphea · Dec 05, 2010 at 08:03 PM

Thank you for the answer. I changed it, but I get a new error msg:

Assets/Script/cutscenes_trigger.cs(24,26): error CS0119: Expression denotes a Invalid', where amethod group' was expected. This refers to the line : isCutscene = true;

using UnityEngine; using System.Collections;

public class cutscenes_trigger : MonoBehaviour { public GameObject cuts_cam; public GameObject main_cam; public int questID; private bool isCutscene = false;

 void Update() 
 {

     if(QM.Ins.GetQuestStatus(questID) == questConditions.DONE && !isCutscene)
     {
         isCutscene = true;
         CutScene();
     }
 }

 IEnumerator CutScene()
 {

     cuts_cam.active(true);
     main_cam.active(false);

     yield return new WaitForSeconds(4);

     cuts_cam.active(false); 
     main_cam.active(true);

 }

}

Comment
Add comment · Show 4 · 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 Maarten · Dec 05, 2010 at 08:07 PM 0
Share

I think its not the "isCutscene" line is giving the error, but the next one. Please change CutScene() to StartCoroutine(Cutscene());

avatar image orphea · Dec 05, 2010 at 08:25 PM 0
Share

I get the same error. (Just in case, I let you know I put an uppercase S for CutScene)

avatar image Maarten · Dec 05, 2010 at 08:40 PM 0
Share

Could you post the code that you have now?

avatar image orphea · Dec 05, 2010 at 09:23 PM 0
Share

Ok I found the problem. I had to use cuts_cam.active = true; ins$$anonymous$$d of cuts-cam.active(true); Same thing for all the other statements. Weird... but anyways, it works now! Thank you :)

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

No one has followed this question yet.

Related Questions

Cutscene Segments 1 Answer

StopCoroutine not returning to yield 0 Answers

What am I doing wrong. "Calling Script to start coroutine" 3 Answers

How to properly use blendshapes via script? (c#) 1 Answer

lock a target after a few seconds 1 Answer


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