|
Pretty new to scripting for games, but I've been getting better everyday. However, one script I've been working on has had me stumped for almost a week now. The scenario, I've got two boxes in my scene that act like buttons. Starting out the red box should be the only one allowed to go from grey to red. After the red box is clicked, then the green box can be clicked to turn it from grey to green. I'm not wanting a radical script change that does only this, because this is a beta script for what will eventually be used with more "buttons" and a more complex boolean true/false pattern. The largest problem I faced with this script, is that it does alternate booleans like I want, but not on other object. I put the script on both the green and red boxes, but when I click the red box, the booleans on the green box don't change, so I figure to fix this I'd have to put the script on an empty GameObject, then make these two boxes the children of the empty GameObject. My problem is that once I put the script on the empty GameObject, it doesn't know to change the booleans on the child objects when I click on them individually. Any help would be greatly appreciated, I've been stuck on this for about a week and some folks at the technology center are wanting to see a working script.
(comments are locked)
|

Will there be some sort of sequence pattern relation between these buttons later on? It might be essential to know how many there'll be and you might be better off with an array of buttons and booleans connected to them.
Well there's going to be 4 buttons on the test objects I have. An elevator with a "Close" "Open" "Call" and "Hide", but I'm wanting to be able to apply this script to multiple, similar setups. Like, at the top of the script I have to "var"s where I can drag and drop an object into in Unity. Really the pattern is determined by which buttons I allow to be pressed when another button has been pressed first. Like, when you click the "Open" button on the elevator, I don't want the player to "Call", "Open", or "Hide" (which sends the elevator down), and when they click "Close", then they'll be able to "Hide". Etc.
What's got me stuck is how to put this script on an empty parent object, and have it kind of "listen" to the two objects I've defined. The GreenBox and RedBox will be children of the empty parent.