Announcement

Collapse
No announcement yet.

Change dynamic material via HUD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Change dynamic material via HUD

    Hello,

    I'm trying to change the emissive intensity parameter of a dynamic material instance using a simple slider in the HUD.

    I'm unsure why it won't respond.

    There is a parameter set in the master material.
    Click image for larger version

Name:	lightMaterial.png
Views:	60
Size:	82.0 KB
ID:	1828248


    When the blueprint is spawned it creates a dynamic material instance and assigns it to the mesh component.

    Click image for larger version

Name:	createDynMat.png
Views:	40
Size:	71.3 KB
ID:	1828249

    When I attempt to change the slider in my HUD widget...I dont get a result.


    Click image for larger version

Name:	changeValue.png
Views:	41
Size:	140.5 KB
ID:	1828250


    Is there anything jumping out as being wrong with this ?

    Thanks a lot.








    #2
    How does the widget know which Selected Light it's dealing with?

    Comment


      #3
      Make video else we cannot know what are you dealing with .... Maybe use set material on value change and assign the parameter?
      Some cool unreal projects you may like!


      Developer of GOTA - Survivalism Gladiatorial game Buy the game google gladiators of the arena steam https://store.steampowered.com/app/7..._Of_The_Arena/

      Download the demo Download the demo
      external link Dropbox DropBox

      Become a c++ Professional now C++ Networking Tutorial

      Comment


        #4
        You should follow some tutorial/documentation about blueprint communication.
        Getting infromation out or in to umg blueprints is not easy.

        Easiest way for your case would be:
        - create event in game mode (or other easily accessible blueprint) lets name it "Event_Change_Material"
        - create event dispatcher in same blueprint "Dispatcher_Change_material"
        - from umg blueprint call that event in game mode "Event_Change_Material" when umg is updating slider
        - now you need actor with that dynamic material (and mesh), because to change dynamic material during runtime you need to create dynamic material instance, else it will not change in runtime. So easiest is to have actor and in its construction script create instance, then apply to mesh.
        - in that actor assign to dispatcher "Dispatcher_Change_material" then change material when it is called.

        Problem has 2 separate tasks:
        - signaling actor with material that it needs to change
        - changing material

        So split it in two, first work on communication (ie. print some output when actor gets signal to change material). Then work on changing material. So many problems with blueprints arise when you have multiple errors (bugs) and nothing seems to work, so fix that stuff step by step.
        Last edited by Nawrot; 11-02-2020, 05:48 AM.

        Comment

        Working...
        X