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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

How can i change material color of multiple objects inside blueprint?

I'm spawning a grid inside my level https://i.imgur.com/LrMcZo2.png

Then im creating onHit event for every static mesh created by macro. https://i.imgur.com/DswKFnm.png

Now every player have assigned different color (e.g. player1 : blue, p2: red etc.), so instead of duplicating same material over and over for X colors i want to assign base color based on player color.

As you can see in BP screenshoot i want to replace 'set material' with something that will allow me to change base color of material. I know i can achieve that by using 'set vector paremeter value' , but i dont know how to exactly create dynamic material instance and then call onHit to change color of exact object that character just hit.

Product Version: UE 4.18
Tags:
more ▼

asked Apr 17 '18 at 09:27 PM in Blueprint Scripting

avatar image

Tafonath
17 4 6 11

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

You were on the right track with Dyanmic Material Instance. If you create a dynamic material instance in the construction script with a material instance that has exposed parameters for the values you want to change.

alt text

Then you can simply change the parameter whenever you want, even lerp it if necessary.

alt text

alt text

createinstance.png (65.2 kB)
setcolour.png (61.4 kB)
more ▼

answered Apr 17 '18 at 09:53 PM

avatar image

Ruffhaus Games
658 13 9 22

avatar image Tafonath Apr 18 '18 at 03:36 PM

Yes, i knew about it, but since it's not a single mesh but grid of meshes i couldnt figure it out. What I've done is upon construct every instance is added to array, then on component hit I search through array of meshes (also created in construction script) to get index, and i use this index to get exact tile from grid and set it color with vector paramter value.

https://i.imgur.com/SlPpjpP.png

https://i.imgur.com/virOZXr.png

(comments are locked)
10|2000 characters needed characters left
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