hey there. my script here is really annoying me because when ever i put it on a door and the tags and that are working but it keeps on looping only the (!stat) and i can’t get it to switch to (stat). it would be greatly appreciated if someone could help fix this script, thanks
public var stat : boolean;
public var able : boolean;
var open : AudioClip;
var clos : AudioClip;
function Awake () {
if(stat){
animation.Play("openstat");
}
}
function OnTriggerEnter( other : Collider ) {
if(other.tag == ("Player")){
able = true;
}
}
function OnTriggerExit( other : Collider ) {
if(other.tag == ("Player")){
able = false;
}
}
function Update () {
if(able){
if(stat){
if(Input.GetKeyDown("e")){
stat = false;
animation.Play("closingdoor", PlayMode.StopAll);
audio.PlayOneShot(clos);
Debug.LogWarning("im now closed");
}
}
if(!stat){
if(Input.GetKeyDown("e")){
stat = true;
animation.Play("openingdoor", PlayMode.StopAll);
audio.PlayOneShot(open);
Debug.LogWarning("im now open");
}
}
}
}