|
This script is for my door. Right now it opens every time I walk into the invisible cube that triggers the door to open. I made a script to pick up a key. Now the big question is how do I change the script below so it triggers only when I have the key. I think I have to somehow call the other script and let this one know I have the key. Door open script:
Below is the pick up script for the key.
(comments are locked)
|
|
You will indeed need to call a function (or access an public variable) on the other object. For the sake of the example, I'll assume the script with the key code is PlayerScript; but just substitute the real name below. The first thing to do is to add a function to get the key state in that script
Then in your door script, you just need to grab the script on the player object using GetComponent(type). Once you have the component, you can call any public function (or access any public variables, from that script. Thanks. With minor change I made this work.
Apr 22 '11 at 09:16 AM
Noddman
(comments are locked)
|
|
I believe this will work. Key script
Door script
(comments are locked)
|
