Hi all,
I hope I will be clear enough about my problem.
I am creating very simple app or game(on android) where u just type the word and the object connected to that word will disappear(fade animation) and the sound will be played.
How it should work: In the app I touch the screen the native keyboard come up. I type the word the object connected to that word will disappear and the sound clip has been played along with the animation.
Reality : I touch the screen the keyboard come up I type the word, I hit done, the native keyboard disappear, the object disappear animation is played correctly but there is no sound. When I touch screen again the native keyboard come up and the sound clip is played and I dont know why.
I created a empty gameobject and put sound clip to it.Thats how I am trying to play the sound.
Here is the code :
#pragma strict
function Start () {
}
var putString:String="";
var inputString:String="";
var keyboard:TouchScreenKeyboard;
var inv=new Array("laptop","mug","table");
function wordLoop(){
for( var value : String in inv){
if(inputString==value){
GameObject.Find(value).animation.Play("fade");
//Destroy(GameObject.Find(value),1);
GameObject.Find("sound").audio.Play();
//yield WaitForSeconds(1);
}
}
}
function Update(){
if(Input.touchCount>0){
keyboard=TouchScreenKeyboard.Open(putString);
}
if(keyboard.done){
inputString=keyboard.text;
wordLoop();
}
}
Can you please help me where is the problem that the sound is not played along with the animation but after the keyboard comes up?
Thanks in forward.
Martin.