I basically want to make a small puzzle game where you have to hit 4 buttons in a specific order say 1,4,2,3 to move a cube. But if you hit one out of order say 1,4, then 3 it resets the puzzle. The buttons will be small cubes placed in the center of a bigger cube in each corner of a room. The button for 1 will be the only one exposed until pressed, then the others will move out of their larger cubes that they are placed in respectively. Only after the last button is hit in the correct order will the cube in the center of the room move up. Sorry if this isn’t the correct place to post such a question but i need help accomplishing this using javascript.
I wold really appreciate any help anyone can offer!
Sorry for the vague question. I guess what i’m looking for and need help with the most is how i should go about making it so that say an empty game object lets call it “logicbox” can keep track of what buttons have been pressed and how to check if they were pressed in the correct order and if not reset the the buttons? I under stand how to script a button press as function OnMouseUpAsButton but how can i keep track of button presses and make sure that if a sequence of buttons are pressed in the correct order the last button will move another object?
Have a boolean variable in the button. Then store all the buttons in an array inside your “logicbox”. Your “logicbox” will then check if the boolean variable is true (it’s set to true when the player clicks the button). Then check against the sequence. If it’s wrong, reset. If it’s right, do whatever.
Thanks for the reply! That sounds exactly like what i need to do, however would it be possible for you to provide me with an example? I really appreciate all the guys!
Then in your “logicbox” class, you’ll have an array of the buttons and your sequence array. Check if your button is clicked then compare it against the sequence. Then if the first value of the sequence is correct, move on to the next sequence to check.
void Update()
{
for(int i = 0; i < myButtonArray.Length; i++)
{
if(myButtonArray.myBool)
{
if(i == mySequence[currentSequence])
{
// Do Something (correct)
}
else
{
// Do Something (Wrong)
}
}
}
}