Online timer

Hello! So I made a timer that counts down and when it gets to 0 it changes the map. The only problem is that the timer only shows for the host and not the clients. The numbers show, however, it doesn’t countdown. Thanks for any help!!! The first pic is the timer in the multiplayer instance then the second picture is the timer in the game mode and then the last picture is how the time is being shown onto the text.

Hi, keep in mind that the GameMode only exists on the server, so the clients can never access it, it just doesn’t exist there. Further the GameInstance and widgets do not replicate.

You can either

(-) From the server send a Multicast to all clients to start the timer. Then do the timer logic completely local on all clients, when the timer of the server comes to zero change the map.

(-) Do the timer logic on the server only, replicate the current time to the clients (mark the variable as replicated).

Keep in mind that in order to use a Multicast or replicate the current time to the clients, you need to do this on an actor that does replicate and exists on all clients, so neither the GameMode nor the GameInstance (you could use the GameState for example).

Also it might be easier if you would keep and count the remaining time in one variable (as seconds) and only format if you want to display it. Also you can use a timer which will execute every X seconds, instead of using tick and delay.

*The Event should be named “DecreaseTime” instead of “IncreaseTime” =)

Thanks alot!!!

I tried the set timer by function before i used delay but i couldnt figure out how to make it do something after the timer reached 0. There were a bunch of functions like pause and unpause by using the time handel but none of them worked, for example after it reaches zero i want it to change map. ( I have The code for it to change map but i dont know how to make it actually work after it reaches zero)

My second question is that i have done my timer with an actor before
using the game instance and game mode, however, I couldnt find how to make it ‘start’, as in the world settings I can choose the game mode and player pawn but i had no idea how it worked with actors. My actor was an actor blueprints class.

Thanks for all the help!!!

but i couldnt figure out how to make
it do something after the timer
reached 0.

You can check if the remaining countdown time is smaller than 0 and if so call the function/event that you want (and also clear the timer so that it stops executing)

I couldnt find how to make it ‘start’,
as in the world settings I can choose
the game mode and player pawn but i
had no idea how it worked with actors.
My actor was an actor blueprints
class.

Not quite sure what you mean. You can spawn actors via “SpawnActor” from blueprints during runtime and you can drag and drop them into the level from the editor.

Thanks for all the help!!!