In my game you need to press a button to open a door in another room but when I put that in the script and start playtesting it says the object is undefined because it is not in that room. How do I make something in one room affect something in another?
Use a global variable e.g bool door_open;
In one room, set door_open = true when the player presses the button.
In the other room change the door object according to that variable.
You could make a global boolean and turn to true when button is pressed. When you enter the next room you need to, in it's room load, put a condition if the boolean is true and if it is true it will affect object in that room.
Like Matti said, who just beat me (nod)
Thank you. That worked fine.
Hi metalmario991.
Yes. Boolean.
I am at work typing this so it's off the top of my head... but...
In the script header typeimport bool Button_Pressed;
Then in Global script at the top typebool Button_Pressed;
export Button_Pressed;
That's the bool set up.
Now, in the script you have for the button put this Button_Pressed=true;
In the room with you door put inside room loadif (Button_Pressed==true){
//door is open script//
}
else {
if (Button_Pressed==false){
//door stays shut script//
}
Hope this helps.
Bugger too late.(laugh)
Glad it worked.;-D
Ahm... RetroJay, you don't need all that import/export stuff, all you need is to define a Global Variable (you find it on your project tree) and create the variable there with an initial value. Then all you need to do is set it up in the script to change that value, and then the if/else condition to check for the change... ;)
Hi Cassiebsg.
Yes of course.
However I personally prefer to have them in global script.
That way I can write notes beside them and keep better track of what is doing what.
It's just the way I prefer to do it though. ;)
Strazers "other room module" comes to mind :)