Hello there everyone.
I have a problem, need some pointer and opinion. I’m currenctly doing a “skip function” for animation in my app. What it does is, it skip the animation and play the dailog rather than you have to wait for the animation to finished and then the dailog play.So I made this script. There’s two part for the script. One is for skipping the animation, That one work well. Second one is the audio script, having trouble with this one :
#pragma implicit
#pragma downcast
#pragma strict
var voice01 : AudioClip;
var voice02 : AudioClip;
var voice03 : AudioClip;
//Contents
var Content01 : GameObject;
var text : GameObject;
var playAgain : GameObject;
var speek : boolean = false;
static var playOnce : boolean = false;
static var playOnce2 : boolean = false;
var hit : RaycastHit;
function Update()
{
contentOff();
if(playOnce == false)
{
if(GetComponent.<SkipAnimation>().skip == true)
{
skiped();
}
}
if(playOnce2 == false)
{
narate();
}
playMore();
}
function skiped()
{
//Debug.Log("sini");
playOnce = true;
audio.PlayOneShot(voice03);
text.active = true;
yield WaitForSeconds(20);
speek = true;
}
function narate() //The narator tell the story
{
//Debug.Log("sana");
playOnce2 = true;
//Voice Narator and text
yield WaitForSeconds(9);
audio.PlayOneShot(voice03);
text.active = true;
yield WaitForSeconds(20);
speek = true;
}
function contentOff()
{
yield WaitForSeconds(9);
Content01.SetActiveRecursively(false);
}
function playMore() //Repeat the special dailog
{
if(speek == true)
{
playAgain.active = true;
speek = false;
}
else
{
speek = false;
}
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Input.GetMouseButtonDown (0)) //Returns true during the frame the user touches the object
{
if (Physics.Raycast (ray, hit, 100))
{
if(hit.collider.tag == "0")
{
//Voice Upin Ipin
playAgain.active = false;
audio.PlayOneShot(voice01);
yield WaitForSeconds (voice01.length);
audio.PlayOneShot(voice02);
yield WaitForSeconds (voice02.length);
playAgain.active = true;
}
}
}
}
How do I stop the “narate” function if the “skipped” function is running? Because now if the “skipped” function is running the “narate” function still run.