Why it's doesn't work?

hi, i made color compare color macro and blueprint which is comparing colors of one actor and other ones which colors are diferrent. I’ve created dynamic material for one actor but it doesnt work. there arent any comapring with these objects.

Ps. In the other actors are blueprints alluding to gamemode blueprint.

Hi! I remember your project from your previous posts.

I’m not entirely sure what the problem is this time, but I noticed a few things that look wrong:

First, you don’t need to create a new Dynamic Material Instance every few ticks. Set it up once, either in the Construction Script or on Begin Play in the EventGraph. Then save the Return Value in a Material Instance
. (You’ll need this variable to compare your colors.)


Second, don’t use a Delay in the EventTick. Instead, create a new function that does what your event currently does. In reaction to the Begin Play event, set up a looping Set Timer node to trigger the function. (Your function probably works, but it’s much more expensive than it needs to be.)


The looping timer does the same as the Tick delay (but a bit cleaner). I’ve changed some details in the function but it’s still basically the same Blueprint logic. The biggest difference is that I no longer create a new Dynamic Material Instance every tick. Instead, I only change the Dynamic Material variable I created earlier.

Last and most importantly, in your CompareColor function, the Orange color is currently always compared against the same color (the first in the array). Instead you need to get the material’s current color and compare against that.

I don’t know what the Color_Sun macro does, so I was unable to test this. But at least you’re now comparing against the actor’s actual color. Also, I included a check whether the Get All Actors Of Class returns a non-empty array before trying to get its first entry. Accessing an array element with an invalid index is a common source of problems (“array out of bounds”), so comparing the index with the array length is generally good practise when programming.

I hope this helps you along. Good luck!

thanks for your help again :slight_smile: color_sun macro is comapring colors, but i titled it like that. i do exacly that what you have done in your blueprints, but ive got a problem with connections dynamic material with get vector parametr value. they doesn’t match.

ive got a problem with connections dynamic material with get vector parametr value. they doesn’t match.

Yeah, I had that too at first. The problem is there are two functions with the same name. To get the correct one, you need to pull a wire from Dynamic Material and create a Get Vector Parameter Value node that way.

Alternatively, untick the Context Sensitive box in the node creation menu. That’ll bring up two options for the node and you need to pick the second one with the tooltip “Get the current MID vector parameter value”.


ok, i ve done it. the blueprint i’ve made in my game mode is still needed? or without him it will work fine?

I don’t know. Depends on your project. :slight_smile:

Best if you try it yourself: Press Alt and click on the first wire (between ColorCompare and GetActorsOfClass) to remove the wire. That way your Blueprint won’t do anything, but you’ll still have it if you still need it. Test if the project still works. If it works even with that code disabled, that means you don’t need it and can delete it.

now it’s always failed, and colors are always different, but i know the dynamic material is getting the same orange as other actors with i compare.

My bad!! i’ve got a letter mistake in parametr! Thank you a lot, You really help one more time! Thanks :slight_smile: