Problem with comparing two dynamic materials

Hello,
I try to compare two dynamic materials, which are changing their colors. But all the time colors are not the same, (that thinks my blueprint) but in game, there are the same color orange=orange, green=green. If they are the same comparing macro should say it’s a true , and game still go on, but it’s always ending, so the macro says it’s false, two different colors. What is wrong with this blueprint? I will add that yet when i compared dynamic material with one specifed color, macro works perfect, it’s only doesn’t when i compare two dynamic materials.

Any advice? Thank You in advance for your help!

You can’t compare two values from two different branches of the Sequence node. What currently happens is that when you call the Color_Sun macro, the Random actor is still unknown and you’re comparing against some kind of default color (probably white or blackk).

Also, if I understand your code correctly, the Random actor (that gets destroyed if the colors are the same) already is the Input parameter of the ColorCompare function. That means, you don’t need to use GetAllActorsofClass “Random” because you already have it.

Here’s my attempt to improve your code.

I’ve got warning in my blueprint now : “Random” is already “Random”, you don’t need “Cast to Random”

Ok i had a event, not function. When i make it a fuction there aren’t any warnings. Now i will test is it comparing colors correct.

The same story. Colors aren’t comparing correctly, because if i hit purple when color changing actor is purple game restarts, like this is not the same color.

So anyone know answer how to compre two dynamic materials colors?

I’m running out of ideas. It would be interesting to find out what the program thinks the two colors are. Luckily, you can find use the Debugger to find this out.

Please put a breakpoint on the Branch node after the Color_Sun macro: Right-click on the node and select Add Breakpoint. (The node will be marked with a red dot.)

60009-addbreakpoint.png

Then start the game. The next time you click on an actor and the program enters this function, it will stop at this breakpoint. You can then hover your mouse over the GetVectorParameterValue Return Values to check if the colors (in RGB format) look correct.

I don’t have the test project here right now, but here’s a screenshot of how it looks in one of my own projects:

If the actor you clicked on is the same color as the Random actor (the score should increase), post both values here.

To remove the breakpoint again, right-click on the node and select Remove Breakpoint.

60010-removebreakpoint.png

Also, while Debugging, there’s a new toolbar. Click on Resume to continue the game until it reaches the next breakpoint. Stop will stop the game (same as when playing normally).

maybe the problem is in my random choosing blueprint?
It’s look that:

Colors are 5 numbers, and it’s choose one of this number, and spawn actor in this color