Randomly change color of object

Hello guys,
I’m developing a turn based game where I have 20 cubes displayed. Each turn I want a random block to change color to black and, when a block changes color twice the game ends. I want to be able to “repair” the block too so I can delay the end of the game.
Do you guys have any suggestion for me? I have an old project (4.13) that does everything that I need but I do not know how to copy it for my project or, at least, how to see how the other person did it.
Thanks in advance!

In the get all actors of class node set the actor class to your cube blueprint then create a black material and use it in the set material node. This will get a random cube and change its color to black. To “repair” it, connect your repair event to a set material node, and change it back to its original material.

Thank you so much, I will definitely try this out!
I’m a newbie but I think that I will be able to do this.

I’m having some problems. I created all the 20 cubes, but I don’t know how to have just one blueprint for all of them.

there are many ways to have one blueprint that would affect them all / control the behavior. you could have the script in the level bp, the game mode, or in a dedicated actor for example.

also to actually accomplish what your looking to do will require much more scripting than what is shown above.

heres an example that shows a bit more on how to implement what your asking about. mainly the part between the get node and the branch is what id highlight here. what that part does is the testing to see if the cube has already been changed to the secondary material (aka the bad one in game). if it has been changed then it triggers game over, if not then it sets the material. its a simple basic test. i wrote this in the level bp but in your case you probably want to writing your script in the game mode.

Thanks a lot man, I think I’m starting to understand how I will need to do it. I will bother you guys again when I find more problems trying to do this :slight_smile: