|
I have got a script that works to unlock and open a door, but I was wondering if there is a way to pick up a key first to open the door and it won't work without that key. I can show you the code I have already, please let me know how I can do this.
(comments are locked)
|
|
You have to assign a boolean variable to your Player, that says if the key has been already picked up or not. At the beginning this variable will be equal to false; When the Player enters in a collision with the key, it will turns into true. Then, you add this variable's truth as a mandatory event to open the door. Something like this: @BiG - you want to check this code your wrote: Think should read:
Apr 24 '12 at 05:47 PM
Fabkins
Okay, thanks, i'll give it try
Apr 24 '12 at 05:49 PM
cycoclash25
I can't seem to get the collision with the key to activate, any suggestions?
Apr 25 '12 at 04:10 PM
cycoclash25
(comments are locked)
|
|
Well all you need is another variable: Then have another object that is a key that when is picked up calls "foundAKey()". Note this is a two sequence action as coded. The first action on the locked door unlocks it and the second action opens the door. Give your key object a similar script that does a ray cast. PS I would probably also not do the Raycast test this way if you had lots of doors this could get computationally expensive. I would have a player routine that does a raycast and detects what it hits. Then depending on the type of object perform the appropriate action.
Apr 24 '12 at 05:42 PM
Fabkins
I have no idea what a raycast is, and I see no reason why money is an issue. I suck at coding, so i'm not exactly sure how to go about doing that
Apr 24 '12 at 05:47 PM
cycoclash25
Well dont worry about it for now. Get something working and optimise later. Enjoy :)
Apr 24 '12 at 05:49 PM
Fabkins
(comments are locked)
|
