Download

access scalar parameter of a material in actor blueprint

Hello,

I’d like to know how can I access a scalar parameter that is connected in the emissive slot of an assigned material in an actor blueprint.

I want to make an event that makes a light bulb switch go on and off, so when I press “E” the emissive scalar parameter will go up to 6, and when I switch the light off the emissive parameter will go back to 0.

Thanks.

In the Blueprint of the Lightbulb, get the Lightbulb Model and call “Create Dynamic Material Instance” on it. Save that in a Variable.
You can call “Set Scalar Parameter” on this Instance. You need to pass a name and a new Value.

Now you can add Events to your Lightbulb Blueprint that interact with this Material Instance.

Thank you eXi for your fast reply.
I made it work like this:
2d0ad22afbbcafea6dfd8865b425b18e3841d67e.png

but I got lost in your explanation a bit. Could you create a quick blueprint to explain your method. Specifically I couldn’t make a variable of the create Dynamic material Instance, since I didn’t know what kind of variable to make.
Thank you.

You can always drag out the “ReturnValue” wire and release your mouse on an empty EventGraph place. In the Context Menu you can then find “Promote to Variable” which will
create a variable matching the ReturnValue Type! (:

This is ok, but with the thing i explained above, try to create the Instance only ONCE in the Construction Script or BeginPlay Event and then use the Variable to call the SetScalar stuff on.
Otherwise you create a new Instance every time you hit F.

Great, I didn’t know that about the ReturnValue :slight_smile:

Thank you very much for your help!