How to get a server created timer information from a client?

Sooo say I created a timer on authority only and wanted to retrieve the “remaining time by handle” from a client, how would I go about doing that ?

I’m using the remaining time and the initial timer length to feed into a progress bar on a UMG widget in order to show a powerup’s remaining time to a player.

As an example I took the networking content example and tried to implement the following which returns a big fat zero on the client. I thought the value would show up on the client since I’m replicating the “float value” and the server definitely knows about the “timehandle” variable.

Any thoughts on how to retrieve timer info from a client’s perspective and feed that into an UMG widget ?

The are timeline component, which have built networking functionality, besides that i can’t think of efficient way to do so.

Ahhh yes haven’t thought about that. I’ll try with a replicated timeline.

Any downsides to using a timeline versus a timer though ?

But one thing that puzzles me a bit is… Say I create a timer on authority and I set the timer handle to be replicated… Should’t the client be able to snatch it and get values from it (remaining and elapsed time for example?).

Timeline is bigger, quite literally, its component. If you don’t need thousands of them it would be ok.

You can test those timer questions, but i highly doubt its how timer work. I didnt dig the source, but i imagine timer is actually some sort of component in engine, which keep track of time and call functions by pointer from its library.

Your timer does need to be replicated (you can tell it isn’t because it doesnt have those two bubbles on it) alternatively you’d have to build functions that retrieve the value as client call.

So I tried before with a replicated timer handle variable before but without any luck. I’ve linked a picture of my attempt :

Would it be a thing to do the following for an armor pickup (just using the armor pickup thing as an example) :

  • Client collides with a pickup trigger.
  • Only on authority, spawn an actor called “effect” with owner set to the client.
  • On “effect” begin play check if authority.
  • If authority, call a run on owning client function that sets a timer and that also calls a multicast to apply the armor boost effect.
  • Once the timer (created on client from server) is over call a run on server function asking the server to remove the armor boost.

I was thinking of doing this since I can only create an UMG widget on a local player… that way I can pass the timer into the create widget function and have a sort of “correct cooldown feedback” with a progress bar.

But yeah… my understanding of networking principles only go so far right now.

From my point of view replicating timers is bad practice… I would suggest you going in different direction. There is no sense in replicating timer statuses. Since you know their time on both sides - you can start them on both sides:

  • on client side you will only use
    it to show progress on user interface
    (even every frame).
  • on server side
    it would take care of your gameplay
    logic.

If you need reliable acknowledge after timer elapsed, set replicated status variable on server side or fire multicast event.
ex: Dota2 Skill cooldown progress does not have to be replicated every tick or every 0.1s. User interface can run it’s own timer locally. After cooldown time timer on server side will change skill replicates status to “ReadyToUse”.

btw.
Handles are not replicated because “timer” is a local resource… or entry in delegate list somewhere in engine main loop.