- Home /
getting a door to open after a puzzle has been completed
I was just wondering if there is a way to make a door open after a puzzle has been completed. In this case a set of 4 levers being pulled in the correct order.
Yes, there is a way to open a door after 4 levers are pulled in a specific order.
Answer by Byterunner · May 09, 2011 at 04:39 PM
This is totally possible. How it is implemented, though, is completely wide open. You can do this in any number of ways. If you're not sure about ideas, here's one way you could do it:
- Store a list with the order of the levers.
- Store an integer with how many levers have been pulled.
If the user pulls a lever, check the current lever being pulled against the list of levers to see whether it was the right one. If it isn't, reset the levers and the integer of how many levers have been pulled. If it is, increment the integer. When all levers have been pulled, execute the door opening script.
Now go write it!
Answer by MrLolEthan · Oct 12, 2012 at 03:07 PM
Your gonna wanna do something like this:
Declare a variable called "openDoor"
Make it a boolean (using ": boolean" if you didnt know
Make it = false
You should have something like this: `var openDoor : boolean = false;`
Now you want so if the levers are pulled in the correct order than it will execute a block of code
You want that block of code to contain this (if you used openDoor for your variable name): openDoor = true;
In your update function write this (if you used openDoor var name):
if(openDoor == true) { //put your code you want executed when the levers are al pulled in order in here: }
Thats it! Good Luck with your game! Sounds like it will be fun!
Your answer
Follow this Question
Related Questions
Puzzle open door ? 1 Answer
Walls with doors in Unity3D 1 Answer
Door Width Gets Smaller When Rotated 0 Answers
Puzzle Box Level Complete - Help Needed! 2 Answers
OnMouseUp is nulling inputs 0 Answers