- Home /
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 because
void' 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);
}
}
Answer by Maarten · Dec 05, 2010 at 07:48 PM
Make the void a IEnumerator. So it changes from:
void CutScene()
to:
IEnumerator CutScene()
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 a
method 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);
}
}
I think its not the "isCutscene" line is giving the error, but the next one. Please change CutScene() to StartCoroutine(Cutscene());
I get the same error. (Just in case, I let you know I put an uppercase S for CutScene)
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
Follow this Question
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