Ok, so there is a problem that I have that I want a door to open, and the door only opens when you have a key… That has all worked great, and I am going to tell you the script I use in a sec, but that is not the case… When I open the door it doesn’t play the sound I want it to play!!!
Here is my script:
var haveKey = false;
var inZone = false;
var noKey = false;
var door : GameObject;
function OnTriggerEnter()
{
inZone = true;
}
function OnTriggerExit()
{
inZone = false;
noKey = false;
}
function Update()
{
if(inZone == true)
{
if(Input.GetKeyDown(“e”))
{
if(haveKey == true)
{
GetComponent.().Play(“open_door”);
Destroy(door);
} else if(haveKey == false)
{
noKey = true;
}
}
}
}
function OnGUI()
{
if(inZone == true)
{
if(noKey == true)
{
GUI.Label(Rect(10, 10, 150, 150), “”);
GUI.Label(Rect(10, 10, 150, 150), “It won’t open!”);
}
}
else if(inZone == false)
{
GUI.Label(Rect(10, 10, 150, 150), “”);
}
}
what am I doing wrong right here, If you need more information please tell me And one more thing, it would be best to get info in JavaScript
Thanks