Set the play time once only in material (UE4)

Hi,

I am working on a project and I have made a material that appear on a character, like a healing buff effectt, I am wondering is there any way to play that appearing effect once only though the material by no parametre control, just use Time to play it once. Now it keep repeating over and over again.

It has been driving me crazy these days. Hope someone can help for that. :sob:

Thank you

If this is just a material and not an effect system like Niagara, the easiest would be to have some kind of control over when to play / when to finish playing the effect through blueprint.

if itā€™s an effect on a permanent actor (like a character) itā€™s material, you cant.
In such cases, youā€™ll always need a little blueprint or other means to make it activate and deactivate.

If its possible, I must have missed something in this last decade :stuck_out_tongue:
(which is very well possible :p)

Thanks for the reply, I thought I could simply just do it in the material. :sweat_smile:

You probably want a Dynamic Material instance ā€“ itā€™s a type of material whose parameters you can change at runtime in a Blueprint.

Hereā€™s how it would work:

  1. First, create a parameter in your material to allow you to fade the effect on and off
  2. Create a dynamic material instance of that material in your blueprint constructor, and assign it to your character
  3. When you want the effect to happen, change the parameter to blend the effect on and then off (probably using a timer or a curve)

I believe there are some examples of Dynamic Material usage in the UE docs. Or probably tutorials. But thatā€™s exactly what you want ā€“ itā€™s designed for this use case.

I donā€™t think this is possible. Iā€™ve been looking for this myself and couldnā€™t find a good solution.
The easiest is to set the StartTime vie blueprint (no need to create a dynamic instance btw, you can just set scalar directly).


If you donā€™t want to create blueprints for this every time, you could do a more generic solution via a Material Parameter Collection. E.g. you have a few different StartTimes params in your MPC and you set the one you need via a generic blueprint. This at least means you donā€™t need a direct reference to your material.

1 Like

@Luos_83 @FRGFX @BinaryBobby @TobiasTobasco
Thx for the solution, about the time value between 0 to 1, if I have a negative time like -1 to 1, is it going to cause bug, should I always make it 0 - 1? (sometimes it need so many calcution to return the value :upside_down_face: and I got confuse most of the time so I usually leave it as the way it was)

Since Twitter brought me here, Iā€™ll give my thoughts on the issue:
Mathematically the solution by @TobiasTobasco works as long as youā€™re not using negative numbers as the duration (But why would anyone do that?). I would suggest updating the StartTime using Primitive Data. One issue I see here is that the effect will stay ā€œonā€ indefinitely after the duration. This could be fixed by using a ā€œfracā€ node after ā€œsaturateā€.

An alternative route would be to use Timers to modify a single Primitive Data parameter, instead of using Time.

1 Like