# Why it's doesn't work?

**URL:** <https://forums.unrealengine.com/t/why-its-doesnt-work/330763>\
**Category:** Blueprint\
**Tags:** compare, unreal-engine, Blueprint, question\
**Created:** [September 2, 2015, 2:28pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763 "2015-09-02T14:28:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c0b110](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c0b110](https://forums.unrealengine.com/u/anonymous_user_71c0b110)\
**Post date:** [September 2, 2015, 2:28pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/1 "2015-09-02T14:28:26Z")

</div>

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.

 ![56804-image1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/7/947ac84fb82a159e9599e3fdf51d6a1d00943674.png)

 ![56805-image4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/4/114773c62358e3bbf7f64c77eacc379d34522ee9.png)

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_359f4d3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_359f4d3c](https://forums.unrealengine.com/u/anonymous_user_359f4d3c)\
**Post date:** [September 2, 2015, 7:42pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/2 "2015-09-02T19:42:06Z")

</div>

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  
variable_. (You’ll need this variable to compare your colors.)

 ![56871-constructionscript_dynamicmaterial.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/d/eed051e8d3f677a24f6506481c96a912b3cf8e62.png)

![56873-dynamicmaterial_variable.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/6/d/d6d4182c0304a7669ce1f363895df3daf1ecdb3e.png)

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.)

![56874-loopingtimer.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/0/7f057eeab84167a8fc8bfe578c2cbd5cb8dbaef7.png)

 ![56875-colorchangingfunction.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/c/5cc8f94a0b2bcf47aeb04b99eab7c1e73abd9c09.png)

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.

 ![56876-comparecolors.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/1/fe1b7e0803b6ba31d804e0c965fc184854d562ba.png)

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!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c0b110](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c0b110](https://forums.unrealengine.com/u/anonymous_user_71c0b110)\
**Post date:** [September 3, 2015, 4:55pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/3 "2015-09-03T16:55:44Z")

</div>

thanks for your help again 🙂 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.

 ![57032-image.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/5/2/252e4aef285cfec503c697e18bd8c40c741bebf4.png)

 ![57033-image4155.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/9/5/895d89a26532cbb9eb09547520239af58d9987e4.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_359f4d3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_359f4d3c](https://forums.unrealengine.com/u/anonymous_user_359f4d3c)\
**Post date:** [September 3, 2015, 6:10pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/4 "2015-09-03T18:10:19Z")

</div>

> 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”.

![57029-getvectorparametervalue.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/6/43686865889c515778e4097be1d90e1a244a323c.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c0b110](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c0b110](https://forums.unrealengine.com/u/anonymous_user_71c0b110)\
**Post date:** [September 3, 2015, 6:23pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/5 "2015-09-03T18:23:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_359f4d3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_359f4d3c](https://forums.unrealengine.com/u/anonymous_user_359f4d3c)\
**Post date:** [September 3, 2015, 6:39pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/6 "2015-09-03T18:39:04Z")

</div>

I don’t know. Depends on your project. 🙂

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c0b110](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c0b110](https://forums.unrealengine.com/u/anonymous_user_71c0b110)\
**Post date:** [September 4, 2015, 2:55pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/7 "2015-09-04T14:55:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c0b110](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c0b110](https://forums.unrealengine.com/u/anonymous_user_71c0b110)\
**Post date:** [September 4, 2015, 3:18pm UTC](https://forums.unrealengine.com/t/why-its-doesnt-work/330763/8 "2015-09-04T15:18:23Z")

</div>

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