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"

Change Texture of Material

I'm drawing a blank right now. I have a material applied to a bunch of different objects in my scene. I want to press a button and a texture of that material changes to a different texture. What is the best way to go about doing this?

Product Version: UE 4.21
Tags:
more ▼

asked Dec 06 '18 at 07:57 PM in Blueprint Scripting

avatar image

DMHokie
63 12 22 28

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

1 answer: sort voted first

You can use the dynamic material instances for that.

To make this work, you need to set your texture inside your material to Texture Sample Parameter 2D (you can do this by e.g. right-clicking your texture node and choosing Convert to Parameter). Name it however you want.

There is a Create Dynamic Material Instance function - as a Parent you set your base material. Then from the output of this function you can call the Set Texture Parameter Value function to specify a new texture on that material. Use the previously specified parameter name here.

The rest depends on your scene setup, blueprint setup, etc. Basically you need to create the dynamic material instance and apply it to your meshes that you want to change. Then use reference to this dynamic material to call the SetTextureParameterValue functions to change the texture. You can do it in your Level Blueprint as a quick test.

I also found some additional info on that here and here.

more ▼

answered Dec 08 '18 at 12:47 PM

avatar image

Slavq
1.9k 148 143 199

(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