Dynamic Material for WidgetComponent

Hello,

I’m trying to change the material of a widget component in blueprint. I have try to “Create Dynamic Material Instance” but it’s look like it isn’t working for WidgetComponent. I have correct result if i’m using the interface or if i apply the result on a staticmeshcomponent. If someone have a solution for my problem, i listening :wink:

PS : I need a DynamicMaterialInstance to be able to change a parameter.

251281-capture.png

I’m trying this :

251282-capture2.png

and the result is this :

251283-capture3.png

Instead of this :

251284-capture4.png

1 Like

It’s a bit of a strange approach.

Normally, you would make a dynamic material and apply it to a 2d widget and then display it in a 3d widget.

Is there a reason why you cannot use this method?

I’m from Unity and I’m only using Unreal for 2 weeks so i’m open to every solution. My Material is playing with vertex, can i do it if a applying my material to a 2D widget?
Btw: what’s the difference between a 2d widget and a 3 d widget?

No. Definitely no. 2d widget material is exceptionally simplistic.

In this case, find the material the 3d widget is using, make a copy, move it to your project, open that copy and add the code you have in your own material on top everything else it is doing.

This way you’ll preserve the pass through material (there’s like 5-6 different versions there - I think they’re actually dynamic instances, too) and can add your own fancy stuff to it.

Untested, never seen anyone trying to do it. Let us know how (if) it works out!

I think it’s already what i have.

I have a WidgetBluePrint (with regular shader)

I have a WidgetComponent in my Actor.

I have a custom material witch is a copy of default shader and when apply in the field, it’s working.

My problem happen what i try to set the material of the widget by script.

So MI_ScoreMaterial is based on the pass through material?

yes it’s a copy of Wideget3DPassThrough

Tried it myself and I’m getting the same result as you. I’ll fiddle with it out of sheer curiosity and report back if I find out why it doesn’t work.


Is there any particular functionality you’re expecting from the setup? I assume you’ve chosen a 3d widget because of a certain interaction type?

I have 2 effect in my material:

  1. A billboard effect (always looking at the camera) (doesn’t need dynamic effect)
  2. A pixel like disappear. (which need the dynamic effect).

I will try to make 2 materials. One on the 3D object or the billboard and an other for the 2D object. I this the solution i want but it’s a solution.

This solution is working… the bug is still there but i get around it :wink:
Thanks for your help.

Glad to hear you found a satisfactory workaround.

Still not sure why widget component is happy to use a material instance but the dynamic material is a no-no. :expressionless:

I’m experiencing the same issue and don’t quite understand the solution mentioned above. Is there any way to use dynamic materials on widget text?

Ran into this today; Looks like this bug still exists. Haven’t found a work around.

A bit late, but if anyone else is wondering, it already has dynamic built in at runtime. You just need to give a tiny delay before attempting to use it:

10 Likes

Geez. Brilliant.

I’ve been stuck on this for a solid hour. Kept searching and run into a thread where I give someone else unsatisfactory advice…

Thanks!

I have also been stuck with this problem for a while, I can’t believe the answer was so simple! Thank you very much!

@Everynone @SireRagnarok @Juice-Tin

I’m on this issue also. As soon as I apply a Dynamic Material to the widget component, the material goes to default.

from this
image

to this
image

A delay is not fixing the issue, as suggested before.

What I’m trying to do is to animate the widget mask with a flipbook. I’m using a copy of the orginal widget master material. Added the flipbook and that’s all. It works PERFECT with a “normal” material instance.

But as soon as I try to animate the flipbook (in sequencer or by manually assign a DynamicMaterialInstance, it breaks.

You guys seem to have found a solution to this, but I’ve beet trying for a while unsuccessfully, so let’s bump this thread again.

As soon as I apply a Dynamic Material to the widget

The trick is not to apply it. One already exists.

1 Like

I was using a “Get Material” node instead of “Get Material Instance”!!

Now, this is working fine:

Perfect. I’ll use this method as a workaround.

I need to control the flipbook progress from a Level Sequence. That is still not working,

I’ve captured what happens:

It seems the Sequencer animates materials by assigning a new Dynamic Material. Who knows.

But I can use the timeline method above, calling it from a Sequencer Event. Not too bad, and I need this working whatever it takes. I’ll ty it tomorrow.

Thanks!

Hey @Everynone (and to anyone in the future trying to animate widget materials with sequencer), I’ve just found the perfect “hidden” solution on this providential YT tutorial:

In fact, that trick with the name of the function Set+variblename is a HUGE feature to get control on anything from sequencer. Is it documented anywhere?

This way, animate the widget component flipbook from sequencer is as easy as creating a variable and a function, like this:

And that’s all. Just let that variable and function to exist in the blueprint. No Begin Play, Event construct, or any dynamic materials management needed. All you need is in this screenshot.

EDIT: It’s even better: With this method the Sequencer is much cleaner and easy to handle! No need to create a 3-level nested track (Component/Material/Parameter) to access the parameter. Just a single parameter track. This makes your life much easier if you’re working with complex sequences, as I’m doing now,

Awesome! Today I’ve learned something huge for the type of apps I usually do.

have a nice day!