How to get System Time inside a Material Blueprint?

I need to be able to read the local system’s time of day in seconds in real time to be used for various functions inside the material. The only time-related node that is available within the material blueprint, Time, is useless, as it does not have anything to do with real time, but instead being useful for things like UV panning or sines. After trying to find a solution online, I have found vague mentions of being able to have another blueprint feed the material various things, including system time. How do I do this?

  • If you can get real time in simple Actor blueprint, you can create DynamicMaterialInstance in it and pass that time into material as some scalar parameter.

  • If you understand how materials system works - you can create your own material node and pass system time with it.

  • If you read Time function documentation - you will see that this function returns game time in seconds, which is really similar to what you searching for.

Hi,

I think the first option that @redbox tried to say is this;

Create a Blueprint Actor;
On EventBeginPlay (or any other event that suit for you) you create a dynamic material instance, then push from the Return Value a Set Scalar Parameter (or any other parameter that you want to set), then you get the Get Real Time Seconds and plug into the value of the parameter node. Remember to write correctly which parameter you want to set (image below):

You can add a Static Mesh Component which is the Mesh that you’re using the material, then you can use normally on your levels without difference

One more question. Get Real Time Seconds’ tooltip is Returns time in seconds since world was brought up for play. That doesn’t sound right. Shouldn’t I instead be using Now which says Returns the local date and time on this computer?

Oh!! I haven’t noticed but Get Real Time Seconds really is the same thing as @redbox said earlier, it starts to count after begin play and stops after end play. Sorry :frowning:

The correct node should be Now, then you get the time in seconds, minutes, hours, etc.

262765-capturar.png

1 Like

Thank you, you were really helpful and everything functions as it should :- )