- Home /
Question by
Mannfred · Apr 12, 2013 at 06:07 AM ·
triggerpausemovietextureactivation
play movie on trigger
what I want to do is when you enter a trigger, you are given a question that needs to be answered. then you click on button to spawn you to a different place and a video starts to play. I have got it all so far right but here is my problem. after all of this the game pauses and the video does not disappear. It is if the code doesn't continue before the yield that I have placed in the code.
Please help..
here is the code:
(For the Trigger)
var spawnPoint : GameObject;
var fpc : GameObject;
var pointPlane : GameObject;
var planecorrect : GameObject;
var planefalse : GameObject;
function OnTriggerEnter () {
Screen.showCursor = true;
pointPlane.active = true;
planecorrect.active = true;
planefalse.active = true;
spawnPoint1 = GameObject.FindWithTag("SpawnPoint1");
fpc.transform.position = spawnPoint1.transform.position;
Time.timeScale = 0;
GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false;
GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = false;
}
(for the button on click) :
var pointPlane : GameObject;
var planecorrect : GameObject;
var planefalse : GameObject;
var moviePlane2 : GameObject;
var movTexture : MovieTexture;
function Update () {
if (Input.GetMouseButtonDown(0)) {
pointPlane.active = false;
planefalse.active = false;
Screen.showCursor = false;
moviePlane2.active = true;
moviePlane2.renderer.material.mainTexture = movTexture;
movTexture.Play();
moviePlane2.audio.Play();
Wait();
planecorrect.active = false;
}
}
function Wait() {
yield WaitForSeconds(5);
planecorrect.active = false;
moviePlane2.renderer.material.mainTexture = movTexture;
movTexture.Stop()
Comment