How to compare colors?

Hi,
I want to do simple blueprint which will compare colors.
i’ve got one actor with dynamic color which is changing his colors automatic for example: blue, red, white, black, grey. I named him ACTOR A. And 5 other actors which one has got different color. One is black, second is blue etc… They are maked by the same material like actor which is changing color automatic (ACTOR A), but they are all time in one same color as started. And i want it works something like that:

  1. If i destroy blue actor when ACTOR A has got blue color the game is still going on.
  2. If i destroy blue actor when ACTOR A has got purple color the game is over.
    Have You got any idea? i really need help with that.

To compare 2 Colors you can create a macro for that like this

will it fix my problem? :slight_smile:

Now i’ve getting error

What is wrong now?

tested it again and did not get this error

so what is incorrect in my blueprint?

if you use the macro in your graph , try this :

55868-test78.png

its compile now in graph, but i dont know will it work in game

i recreated the macro without any errors, so maybe try deleting the BreakLinearColor nodes, and remake them by dragging off the inputs.

if you want to compare similar colors, instead of exact colors. you can convert RGB to HSV, and use NearlyEqual on the H values, to compare Hues.

so where i must script this blueprint? I want it looks something like that:
There is one big actor which is changing his color automaticaly around the gameplay. There are also some small actors with different colors. And if i destroy small purple actor when big is too purple color in this moment the game is going on. But if i destroy purple small actor when big actor has got red color, the game ends. I want it looks like this in practice. So when i should write this blueprint?
a) only in big actor which is changing color around the gameplay
b) in all small actors in game
c) in small actors and in big one
d) in level blueprint
Please tell me this, beacuse i really dont know what i should to do now :confused:

that sounds like a game rule, so it should probably go in the GameMode blueprint. but you could put it into a blueprint macro library or blueprint function library, which can be called by each of the small actors, in a custom event that is triggered when you interact with the small actors.

i’ve touching in it on mobile device so trigger is need for it?

each of the small actors can have a Touch event in their event graph, and that can GetGameMode, cast it to your CustomGameMode, and then call the CompareColors function in your game mode. your game mode, on begin play, can either spawn all of these actors and get a reference to them, or it can use GetAllActorsOfClass, and loop through the array to get access the properties of the actors.

And how i can define the big actor color is correct, and if i hit wrong color small actor the game is end? How to compare big actor to small ones. I have done macro for all possible color compares, and now i want to build some blueprints which shall compare small actors colors to big actor color.

And now in my GameMode blueprint i add this blueprint, but i don’t know is it good? Can You look at it, and write me what is need to repair?
And after this patch to blueprint wht else i need in actors blueprints?

you should only need 1 compare macro, because the first input would be from the color of the small actor, and the second input would be the color from the large actor. also, these color variables that you are using are part of the game mode, when they should be the color variables from the actors. the game mode needs a reference to the big actor, and the color compare should have an input that passes a reference to the smaller actor that was clicked on.

when you Touch the small actor, it should get game mode, cast to GameMode_One, then call Color_Compare, passing Self into the function.

to get a reference to the large actor, you can use get all actors of class, or you can spawn the large actor from the GameMode, and get a reference right after spawning, but the colors you compare need to come from the small actor and large actor, and you only need 1 comparison node.

can You show me on screenshot how You done it?