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"

In BP, how to restore the materials that were set in editor, as opposed to materials set in mesh?

Say I import a mesh, and in the mesh editor it uses "Black" material. Then I put this mesh into the model, and set the material on the actor to "White". Then I make this mesh into a blueprint, and make a boolean to switch the material to a third material, "Green".

I've tried a few methods, but cannot get the material to revert to "White" when required. Instead, it reverts to "Black".

When the switch is active, I have attempted to directly set the "Green" material. I have also attempted to create and set a Dynamic Material Instance using the "Green" material as the parent. Either method changes the material as required.

When the switch is turned off, I cannot get the "White" material restored. If I use Set Material and leave the material pin empty (ie None), it reverts to the meshes default material, ie "Black". I want it to revert to "White", the material set in the editor. I have attempted to save the original materials to a variable using the construction script, but it saves the "Green" material if the dynamic material instance is the active material when the construction script runs.

In this use-case, changing the material of the static mesh asset is not practical, as there are hundreds that import with a default material. Also, I may not want each actor using the asset to have the same material. Lastly, I want the materials to be completely independent, not already being material instances themselves.

How can I fix this?

Product Version: UE 4.20
more ▼

asked Jan 29 '19 at 08:33 AM in Blueprint Scripting

avatar image

1 1 1

avatar image Tuerer Jan 29 '19 at 09:11 AM

You can set the white material in the mesh itself unstead of black: not in the model or a blueprint, but in the mesh editor. Or, if you need the black one to pertain, just set the white material instead of reverting it to default.

avatar image wilson_clough Jan 29 '19 at 09:27 AM

I mentioned in the last paragraph that changing the material in the mesh editor is not practical for 2 reasons (the amount of meshes, and the fact that 2 actors using the same mesh may have different materials). Regarding your second suggestion (manually setting the material in the blueprint to my "default"), I was hoping to have a common blueprint that could be used for many meshes and actors, each possibly having different materials, and thus there is no "default" that can be set in the blueprint. I would like it to be automatic and dynamic, based upon what was configured in the editor.

avatar image Tuerer Jan 29 '19 at 11:01 AM

In this case you can save the default material to a variable on Begin Play or in the Construction Script and create a function that will run for different blueprints with a material stored in the bp variable.

The default material is saved in the mesh asset, and if you change it in the bp and don't save it somehow, it will always go back to the mesh material.

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

1 answer: sort voted first

Here's what I came up with to cache the materials. This allows the material to be set to a different material from within the editor, even if the temporary material is the active material.

alt text

cache-material.png (86.4 kB)
more ▼

answered Jan 31 '19 at 05:50 AM

avatar image

1 1 1

(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