How to Fade In decal on trigger?

Hi, I’m making a horror game where the player triggers a sequence of events, but I can’t make some decals fade in.

And here’s the material. The opacity has to be linked to the texture or else I get a black background.

Anyone who posts the anwser gets a cookie. =)

Hi

Can you post your coding for fading the decals in?

Actually I’m waiting for someone to anwser it too.

In your material, multiply the opacity by a scalar parameter “Opacity”

Then, in blueprint, when the player enters your trigger :

  1. Get your decal actor
  2. Get its material
  3. “Create Dynamic Material Instance” based on this material
  4. Put this new dynamic material on your decal with “Set Decal Material”
  5. Create a timeline that interpolates a float from 1 to 0 in X seconds (to your liking)
  6. At every update of the timeline : “Set Scalar Parameter Value” on the dynamic material : with the parameter “Opacity” and use the current float value from the timeline

Can’t wait for that cookie :slight_smile:

1 Like

Thanks for the fast reply, Violaine. =)

I got your idea and it seems to work like a charm. I’m just having a problem at the blueprint part. If you could help me would be great.

The Opacity for the texture is working just like I want.

Since i’m a newbie at blueprints, I don’t know where goes what. I managed to create a timeline with 2 seconds delay from 0 to 1 (for the Opacity parameter), but I can’t update the value. I can’t even change the Parameter Name.

Oh yeah, that node. The thing is : there are two “Set scalar parameter value” nodes available. One is for Parameter Collections (the one you got) and one is for Dynamic Materials. See how the node wants a collection asset? It’s the wrong one for your needs. That happens often to me too, since they have the same name.

I suggest that you drag out the blue pin from the “Create Dynamic Material Instance” and then type to find the “Set Scalar Parameter Value” node. Since the blue pin is a dynamic material, the context sensitive search will only show the right “Set Scalar Parameter Value” node.

That aside, you also have to connect the output of the “Create Dynamic Material Instance” node (your newly created material) to the “New Decal Material” input of the “Set Decal Material”. Then you also need to connect your decal actor to Target of that “Set Decal Material”. That way the new material will be put on the decal actor.

You’re almost there!

PS: As a general rule, dragging the pin of the element you want to act on really helps to find what you can do with it. Keeping the context sensitive activated and typing to find what you want to do. It will only show nodes that work with that element. Moreover, like in the case of that Set Scalar Parameter, sometimes nodes don’t show up if you don’t have the target element dragged out. You can turn off Context Sensitive in that case to see ALL nodes ever and then figure out what the node requires.

1 Like

It didn’t occur to me that there is also a few different “Create Dynamic Material Instance” nodes. I swear it’s pretty confusing. In your set-up you can simply plug your material (from the decal) in the “Parent” input instead of the "World Context " and it should work! Honestly, I don’t know what this "World Context " is for, and why the material is automatically put there instead of “Parent”. This node takes a parent material and makes a dynamic one based on it. Right now there’s no parent material defined so it doesn’t output anything.

If you want to get a cleaner code, you can use the other “Create Dynamic Material Instance” node. It looks like this :

This one sets the material on the actor in the same node, so you wouldn’t need the “Set Material node”

Ahh, thanks for the heads up about the “duo” Set scalar parameter value. Would’ve never guessed about that.

I have one last problem: My target of Set Scalar Parameter Value seems to only link with Return Value from Create Dynamic Material Instance, but it keeps returning an error on log. Do I have to create another Create Dynamic Material Instance after the Set Scalar Parameter Value?

Btw, appreciate the patience =)

1 Like

Haha, it worked! I don’t know how to thank you enough, but you deserves all the cookies of the world. =) This blueprint system can be quite helpful, but very stressful at the same . Thanks again for the amazing help.

No problem, it was my pleasure :slight_smile:

Sorry to bump an old thread but I found this when googling how to fade out decals.

You can just hook up the Decal Lifetime Opacity node into the opacity, then use the decal actor’s class settings to adjust it - these can all be referenced and set in the event graph. Way easier than using timelines imo!

works fine
thx