- Home /
secret code to open door with sound emission
Hello everybody . I thank everyone in advance for your help. I a building set that there are many doors which open upon entering a secret code . So far my script is working fine , but I would like to open the door was delivered audio , see I put the sound to play when the last character of the code is entered, but the sound is playing on a loop , like that sound stop when the door was wide open , whether or not to enter the trigger , as it stands is ireal , maybe a timer with the command to stop the emission of sound, but do not know how to do that Someone would have a solution for this. thank you
My script:
var close = false;
var CodigoBau : String = "";
var stringToEdit : String;
//var estiloAviso = GUIStyle;
var AngleX : float = 0.0;
var AngleY : float = 0.0;
var AngleZ : float = 0.0;
private var targetValue : float = 0.0;
private var valorAtual : float = 0.0;
private var easing : float = 0.05;
var Sound:AudioClip;
var Target : GameObject;
function SetTheGUI () {
close = true;
//targetValue = AngleX;
//valorAtual = 0.0;
}
function UnSetGUI () {
close = false;
}
function OnGUI(){
if (close){
GUI.Box (Rect(Screen.width/2-60, Screen.height/2-80, 150, 35),"DIGITE O CÓDIGO");
stringToEdit = GUI.TextField (Rect(Screen.width/2-60, Screen.height/2-40, 150, 25),stringToEdit, 11);
if(stringToEdit == CodigoBau){
audio.PlayOneShot(Sound);
valorAtual = valorAtual + (targetValue - valorAtual) * easing;
Target.transform.rotation = Quaternion.identity;
Target.transform.Rotate (0 , 0, valorAtual);
}
}
}
Your answer
Follow this Question
Related Questions
How to code a one way door 1 Answer
I am trying to make a door, when using this script nothing happens. 0 Answers
How do you select a root object from a child's script? 1 Answer
Door Animation, Script Help Please! 2 Answers
Door key code 2 Answers