Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Function Update not working

$
0
0
I have a javascript that is supposed to let you pickup a battery but other stuff happens but when the script gets to the function update, i get errors. Can someone PLEASE help var monster : GameObject; var SoundObject : GameObject; var MeshObject : GameObject; var playerTag = "Player"; var buttonInRange; private var hasPlayed = false; function OnTriggerEnter (c : Collider) { buttonInRange = true; } function OnTriggerExit (c : Collider) { buttonInRange = false; } function OnGUI () { if(buttonInRange == true) { GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Pick up batteries"); } function Update () { if (buttonInRange == true) { if (Input.GetKeyDown ("e")) { if(!hasPlayed) { MeshObject.GetComponent.().enabled = false; yield WaitForSeconds(0.5); SoundObject.active = true; yield WaitForSeconds(2.5); monster.active = true; SoundObject.active = false; hasPlayed = true; Destroy(gameObject); } } } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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