x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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. alt textalt text Ps. In the other actors are blueprints alluding to gamemode blueprint.

Product Version: UE 4.8
Tags:
image1.png (294.3 kB)
image4.png (339.5 kB)
more ▼

asked Sep 02 '15 at 02:28 PM in Blueprint Scripting

avatar image

R4c1o
24 6 7 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

alt text alt text

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

alt text alt text

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.

alt text

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!

more ▼

answered Sep 02 '15 at 07:42 PM

avatar image

erinacea
1.8k 69 28 113

avatar image R4c1o Sep 03 '15 at 04:55 PM

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. alt text alt text

image.png (308.2 kB)
image4155.png (279.0 kB)
avatar image erinacea Sep 03 '15 at 06:10 PM

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

alt text

avatar image R4c1o Sep 03 '15 at 06:23 PM

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

avatar image erinacea Sep 03 '15 at 06:39 PM

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.

avatar image R4c1o Sep 04 '15 at 02:55 PM

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.

avatar image R4c1o Sep 04 '15 at 03:18 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question