|
OK Got something solid to work with but not sure about getting the functionality of it working. I have a key hanging on a wall with a box collider and this script attached: EDIT I updated my Key pickup script so now it works when you press "e".
I THINK and underline that think it's picking it up although I'm very fuzzy on how the whole pickup stuff works. I'm pretty sure I'm doing something wrong as it's supposed to pick up the key when you press "e" but instead it seems to do it when you get very close to it... so I'm not sure if it's actually working right or not. OK so that's problem 1. Problem 2 Here is the script attached to my Gate. I'm not sure how to get it so it recognizes that the FPS player has picked up the key and then how to get that to play the "Gate Unlock" sequence.?
Edit I forgot to add the part in my Player script that should open the gate only if my player has the key:
(comments are locked)
|
|
Problem 1) In this line of code...
You are missing the brackets on your if check. As such, the input is still checking for a button pressed, but the Destroy(gameObject) is getting called regardless of the checks because it is outside the default brackets. Thats why the key is disappearing when you run into the trigger. You actually haven't picked it up until you press 'E'.
That should fix that... Problem 2)
If this code is in the same script and "gotKey" is a global variable, just add another check.
If "gotKey" is in another script you are going to have to send or receive a message from that script in order to get the variable. There are lots of different methods for handling this, so look into it a little. Yes Thanx I had a slight suspicion that it might have been something like that. Now how does my gate know that I have this key?
Apr 13 '11 at 10:47 PM
Michael 12
My "gotKey" is in my "OldGateKeyPickUp" script, how do I broadcast from one to the other?
Apr 13 '11 at 11:41 PM
Michael 12
(comments are locked)
|
