#Marixx weird button thingy
1 messages · Page 1 of 1 (latest)
No, I have 1 Green Button and 3 Red Buttons
When I click the green button, it turns red, and a other RED Button turns green
And so I can go on
Ohh alright
So there's always 1 green button and 3 red ones.
k now I understand
yeah
Let me think
Well the first thing you want to do is change the colour of the green button you pressed.
Once you've done that, take the 3 red buttons and change one of them to green.
You can check what button you've pressed using
string ButtonName = EvenSystem.current.currentSelectedGameObject.name
dont you just want to have a script that has button array with legnth of 3 and green button variables on click randomly select from the array and assign the newly clicked button to the green button and the old back into the array
not said well but thats the logic
That might work
And how do I do that?
which part do you need help with the scripting ?
bit hard when I can't see your setup but will try provide some code
Start with writing pseudocode to work out exactly what you need to do, like this
// Check if a green button has been clicked
// Get a random red button, change it to green
// Change the clicked button green.
Then work out each step
You don't even need an array
@thorn cobalt
But how do I get a random red button?
Make 2 tags. One for green and 1 for red. Store all the objects with the red tag in a list, then get a random one from those
Keep making a new list when you check the tags, because non-active gameobjects shouldnt be found when you check
So I got the logic to work now
But now I am stuck here
how can I make it so it cant choose the same Object twice?
just add a last selected
how do i do that
add another gameobject variable at the top saying lastselected
then you need to do a validation in your switch if the last selected is the same
so an if statement
how do I do that?
would suggest you do a few tutorials first on c# if you don't know if statements
I know if statements but I dont know how I can get the last case and compare it with the new one