Hey guys,
I'm new to AC, so far I found it awesome! I can code but with AC it removed me hours of work. Im doing a simple game for my son and I have a problem.
I want to make a puzzle, simply you have 4 buttons (Objects) when you click on them they change the color (Up to 3 colors each) if all of them are the same color then the puzzle is over.
My issue is, I want to swap the material of each button when it's clicked however I can't do that. Clicking one I can change the material, there is no issue. But how can I make that each time I press it changes to a different one? I tried doing a sequence and it auto runs, then I tried with a popup switch but doesnt work.
In short my main issue seems to be, how can I run the action only when you pressed again in the same object? Not sure if im making any sense and I can't seem to post pictures.
Thx
Comments
So the puzzle is four squares that can change three colors and one they are all the same,the puzzle it is solved (just clarifying).
This is what I would do -
create 3 integer variables - one for each color, leave them at 0
Hypothetically lets say the colors are blue, red, and yellow and change color in that order.
When the puzzle starts off the integer variable for each color should match with how many buttons are of that color. If at the start of the puzzle there is one blue button, one red button, and two yellow buttons, the integers would be Blue = 1, Red = 1, Yellow = 2.
For each button interaction, make three use interactions and disable the last two. The first one will be for color that button will be first (blue), the second interaction will be for that button when its pressed once (red), and the last one is for when the button is pressed a second time (yellow). During each interaction at some point it should change that buttons hotspot interaction to the color it will be turning next, so if the button is blue first the button interaction for blue should change the hotspots interaction to red. Do this for each button.
In order for the game to keep track of how many buttons are of each color, the integer variables will have to change every time a button is pressed. So when the blue button is pressed it will be come red and the variables will now be Blue = 0, Red = 2, Yellow = 2. To do this the interaction should add -1 to Blue and add 1 to Red. Then keep doing this for ever interaction between each button, changing which variable will have 1 added or subtracted depending on the interaction.
Finally, at the end of each interaction all three variables need to be checked to see if they equal 4 because if one of them equals four that means that all four buttons are the same color. So, if none of the buttons equal four then the game should do nothing, but if one of them does equal four than the puzzle should end.
I hope this helps (and makes sense). If you have any questions please feel free to ask.
I'm not 100% sure this will work sense I've never made a puzzle specifically like this before, but at the very least it is a possible working solution.
I'm not too sure I follow completely, I'm afraid - does clicking one object change all, or just the one? Is it changed randomly, or in a set sequence? Images can't be hosted on the site directly, but you can post to any image-sharing site such as imgur.com and link to them instead.
Using a sequence should be the correct approach. Were you linking it to a Variable? It shouldn't be the case that the Interaction is run multiple times with the same click, unless the Actions have been wired up that way. Know that Actions can be assigned comments in the ActionList Editor
window, which can be printed in the Console - see Section 5.2.3 - which may be useful for you when debugging.
Is the problem more to do with the material-changing? You can test the Object: Change material Action on its own by placing it in a separate Cutscene and clicking "Run" in it's Inspector at runtime.
Once this is solved for you, know that you can extend your completed ActionList for others by turning it into a parameterised Cutscene. ActionList parameters (see Section 5.14) work like function parameters in that they can modify Actions they are passed to - see this tutorial.