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"

How do you change the texture on an object with blueprint?

hi all ,

please i would like to know if its possible to make change texture to an object by using a click trigger or something like that ! thks a lot

Product Version: Not Selected
Tags:
more ▼

asked May 15 '14 at 07:56 PM in Blueprint Scripting

avatar image

84rt-design
86 6 14 33

avatar image 84rt-design May 22 '14 at 06:18 PM

so i tryed to make in a custom blueprint but impossible !!!!! some help !

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

4 answers: sort voted first

I also had some trouble trying to figure this out, but I finally made it work. Here is how I did it:

1) First you need to set up your material with a TextureSampleParameter2D (this will allow you to dynamically edit the materials texture during runtime).

alt text

2) In your blueprint you have to create a Dynamic Material Instance and set your actor(s) to use this new material (which is based on the material you made in 1). You can do this in the Construction Script (it should be done at the start of your game, or when your actor is spawned). Also, make sure the Element Index of SetMaterial matches the material you want to set on your actor (if you only have one material then just set it to 0).

alt text

3) Now you can use SetTextureParameterValue to change the texture of the Dynamic Material Instance you created in 2.

(It seems I am only allowed to add two images here. The third image can be found in another comment on this page - dig down!)

mid_step1.jpg (47.7 kB)
mid_step2.jpg (62.4 kB)
more ▼

answered May 19 '14 at 09:48 PM

avatar image

SMillard
66 1 3 9

avatar image SMillard May 19 '14 at 09:50 PM

Let me know if this works for you, or if you have any questions.

avatar image 84rt-design May 20 '14 at 03:58 PM

woah thanks to you SMillard , i'm trying to make it but still complicate for me i don' understand sens of Actor an Static mesh , does your blueprint setup is trigerable with a button ?

avatar image SMillard May 21 '14 at 01:18 AM

Your Actor is the object that has the material you want to change textures on. You can cast your Actor to a StaticMeshActor as shown in image 2 (this is done to get the StaticMeshComponent, which is the target of SetMaterial). Just use a variable to store your Actor (in image 2 it is called MyActor).

Step 1 and 2 must be done first. During runtime, when you are ready to change the texture on your material, you simply use Step 3 - this could be at the press of a button. I'm sure you can find a guide on how to set up a blueprint button somewhere in the Unreal 4 examples or on the forums. Right now I'm just using the event called when the player presses the fire button (InputFire event).

avatar image Shinijami Jul 21 '14 at 10:06 PM

This works when I drag in things from the architecture tab but not with things I bring in with Geometry. Any idea why?

avatar image Clunk47 Mar 11 '15 at 02:41 AM

Thx so much man!! :D

avatar image Discmage Apr 21 '15 at 05:56 PM

Unfortunately the 3rd image above is not available so I cannot see how the SetTextureParameterValue is used.

Many people seem to be using Set material, but I assume this is for the WHOLE material and not a texture within the material...is this correct? All I would like to do is set one texture inside a material to other options...mainly for variant cosmetic item options changing a mask for decals (in my example).

Also, If I am using a Dynamic Material Instance Constant...do I still need to create the dynamic texture in the Construction script?

Any help would be greatly appreciated.

avatar image Discmage Apr 21 '15 at 08:02 PM

Here is my construction and event Blueprint so far trying to emulate what you guys have going... I am trying to get the material instance from this objects blueprint (a cosmetic item) so I can make variants with different masks. The colour variants still work, but the mask doesn't change. Any thoughts? Thanks in advance. My current blueprints.

variants_01.jpg (338.7 kB)
avatar image SMillard Apr 21 '15 at 09:27 PM

Hi Discmage,

It's some time since I worked with this, and I've been away from UE4 for some time. Also, I don't have time to dig into it thoroughly right now, so I'm not sure I can help you 100%. However, I found image 3 for you, and I think what you are missing is the correct parameter name ("Texture_sample_2d"), to match what you set up in image 1. That is, if you did the same as I did in image 1 of course. Let me know if this helps at all.

Also, I am pretty sure you still need to create the material in the constructor; since this is were you actually create the instance of the material. Otherwise I'm guessing it would be null.

Notice the parameter name!

mid_step3.jpg (25.4 kB)
avatar image Discmage Apr 23 '15 at 05:19 PM

Thanks for that third image...I got there in the end! I was doing a few things wrong, some ridiculously simple, others not so much...

The only catch now is to make both the cosmetic colours work AND the decals...as the colours didn't for some reason. Thanks for all your help! I'll probably post the results here once I have it all done so others can use the information.

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

ok finaly i made this ! it s look great and works i can switch material on this static mesh with a loop ,but created in level blue-print ,now i have to make it in an actor blue-print. with trigger

alt text

blueprint.jpg (159.4 kB)
more ▼

answered May 22 '14 at 02:20 PM

avatar image

84rt-design
86 6 14 33

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

all you can just use the set material like so...alt text

set_material.png (79.6 kB)
more ▼

answered May 21 '14 at 07:41 AM

avatar image

SoVeryNiceToYou
6 6 7 14

avatar image 84rt-design May 22 '14 at 10:03 AM

thks you too M.Wardle. change material is what i was searching for too .

do you think it is possible that if i have an object like a board, can i make an event change material with a library of material completely different .

thannnks

avatar image Vaheva Apr 04 '17 at 07:51 PM

@Andrew Wardle post good and only answer. You can select it as solved.

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

Yes, via Texture Parameter in material which you can change in blueprint (or you can use different kind of parameter to change look of material, including one that could switch texture) in material or Set Material node (you would need 2 materials in this case)

more ▼

answered May 15 '14 at 09:21 PM

avatar image

Shadowriver
34.7k 918 164 1095

avatar image 84rt-design May 19 '14 at 09:13 AM

thanks for your answer, sorry ive just another question, is there is a tutorial for this, cause im realy newish for programming game.thks very much

(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