Hey all,
I'm very new to scripting and Unity in general. I'm trying to create a level where the player would hit a switch and it would destroy a gate blocking the way to the end of the level.
var Gate : GameObject; var Key : GameObject; var isSwitch = false; var isKeyHit = false; function Update() { if (isKeyHit == true) { Destroy(Gate); } } function OnCollisionEnter(collision : Collision) { if (isSwitch){ isKeyHit = true; Destroy(Key); } }
Above is the script I wrote, I'm using the First Person prefab for my character and I have a capsule placed on the map to act as the switch and a cube for the gate which both have the above script attached to it. It doesn't work though :(
Can anyone help me out with this, all it needs to do is have the player hit that switch/key so that the gate is destroyed
Any help would be greatly appreciated