|
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.
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
(comments are locked)
|
|
One of the objects needs a non-kinematic rigid body to register a collision. Might be better to keep key values in one object like the player to keep track of things. You can do an OnCollisionEnter(other:Collision){ SendMessage("HitKey",keyNumber)} And then on the gate do a similar send message to say ("HitGate",gateNumber, gameObject) And then on the player script you've got 2 functions called HitKey and HitGate this way you can have a set of keys for different gates on the player
May 03 '10 at 12:05 PM
spinaljack
You were right, my main problem was that I hadn't got the script on my player, great idea about the numbers for multiple gates. Thanks a lot :)
May 03 '10 at 02:27 PM
TerryN
(comments are locked)
|

@TerryN, it's nice that you checkmarked the answer, but remember you can also upvote answers, here and anywhere else, that you think are good.
@Cyclops sorry, still a noob lol. I clicked the arrow above the #1 on the answer which turned it into a 2, I'm guessing that's what you mean by upvoting.
@TerryN, yes, that's, thanks for doing it.