Quantcast
Channel: Questions in topic: "please"
Viewing all articles
Browse latest Browse all 93

Need help with door opening and closing script/animation

$
0
0
So I have a problem I created an animation for my door and that went successfully and my script works just fine. But in my script it opens and closes the door all in one button push. How would I fix this? Here's my code: #pragma strict var theDoor : Transform; private var drawGUI = false; private var doorIsClosed = true; function Update () { if (drawGUI == true && Input.GetKeyDown(KeyCode.E)) { changeDoorState(); } } function OnTriggerEnter (theCollider : Collider) { if (theCollider.tag == "Player") { drawGUI = true; } } function OnTriggerExit(theCollider : Collider) { if (theCollider.tag == "Player") { drawGUI = false; } } function OnGUI () { if (drawGUI == true) { GUI.Box (Rect ( Screen.width*0.5-51, Screen.height*0.5, 102, 22), "E open"); } } function changeDoorState() { if (doorIsClosed == true) { theDoor.animation.CrossFade("Open"); doorIsClosed = false; } if (doorIsClosed == false) { theDoor.animation.CrossFade("Close"); doorIsClosed = true; } }

Viewing all articles
Browse latest Browse all 93

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>