- Home /
how to open two classic double door and windows
i have been using this code, which i have found on this forum and it works awesome, i have encountered a bit of a problem when i tried using the same code on a set of double doors and windows, which both have two doors which both open on its own pivet, i created the animation on the parent which is the window frame, and in the door case the door frame, it works fine, each door opens , but i cant seem to get it to work, this is the code i have been using private var currentDoor : GameObject;
function Update () {
var hit : RaycastHit;
if(Physics.Raycast(transform.position,
transform.forward, hit, 3)) {
if(hit.collider.gameObject.tag == "Door" && Input.GetMouseButtonDown(0)){
currentDoor = hit.collider.gameObject;
currentDoor.GetComponent(DoorScript).OpenCheck();
}
}
}
And this one is attached to each door:
var doorIsOpen : boolean = false;
var doorOpenSound : AudioClip; var doorShutSound : AudioClip;
function OpenCheck (){
if(doorIsOpen == false){ Door(doorOpenSound, "doorOpen"); doorIsOpen = true;
}
else if(doorIsOpen == true){ Door(doorShutSound, "doorClose"); doorIsOpen = false;
}
}
function Door (aClip : AudioClip, animName : String) {
audio.PlayOneShot(aClip);
gameObject.transform.parent.animation.Play(animName);
}
...any help will be greatly appreciated
Your answer

Follow this Question
Related Questions
Help touch button 1 Answer
How to run an animation mouse click. 2 Answers
Animation play error. No animation attached. 3 Answers
how to open two classic double door and windows 0 Answers
Animation Question Open Container 0 Answers