Two timers for two players

Hello,
I have two timers for two players in a multiplayer game, It is a countdown timer, and I want the two timers to be shown for both, But the host sees his timer only working but the other timer frozen, and the player sees his timer only working too…
How can I make an object have events both players can see?

1 Like

Heloooooooooooooooooooooooooooooooooo guys.

Hello. Remember to give your object that displays the timer the multiplayer behavior.

If you have more than one object you can set each object to what player it belongs to in the multiplayer behavior settings. I only used one TimerTXT object to display my timers so I left it as owned by host, gave it a variable “Player”, put 2 in the scene and changed their variable to 1 and 2 so I could tell them what Player they belong to.

In your scene events where you mess around with the timers just add ownership conditions.

1 Like

Sorry it didn’t work for me, I have two players, and everyone has his timer, It begins when he has the turn to play, And I can’t understand how we put “start or reset timer” with " pause timer in the same event.


This is the condition for the timer.

And with clicking start I used " start or reset…" It works but for the current player only, I did it for the opponent and it works for him only too, My problem is to show the two timers for the two players.

Start or reset a timer in the same event as pause a timer is a way to initialize a timer but then immediately pause it so it does not run until you want it to. You could of course wait for your events before you create/start the timer.

Your first image, you really don’t need to make each person running a copy of your game responsible not only for changing their text to match their timers but also the text of every other person in the game to match those players timers too. I will skip aside the fact that how are you expecting them to have access to the values of the other players timers, and instead I will merely point out that the whole benefit of a multiplayer feature is synchronization. Each player can run only their own timer and update only their own text such as in my example, and every player there can see it.

The second image, is the variable player synchronized. Is that a scene timer because I didn’t see a way to desynch them. Anyway check out the very helpful wiki you will probably find your answers there.

GDevelop Multiplayer - GDevelop documentation

Exactly, because when you’re not using the ownership condition, Player1s game is just overwriting seconds2 with countdown2 values which it does not have access to, so 0. And vice versa. If you run into anything else like that just consider if it would make sense to add ownership conditions.

Now it works for both, but the event pause timer doesn’t work.

That should be an easy fix, what is the event to pause the timer?

When the player click the right answer like that

But you have to know that i didn’t use variables for the object( seconds1) or(seconds2) Just like that:

No I said in my first post you wouldn’t need object variables if you were using multiple objects and could declare the owner in the behavior properties. At the time I had no way of knowing if you were using multiple objects or not.

For your event snip, is anything working in it? Like does everything work except pausing the timer? When you say it’s not working do you mean the timer keeps running or does it stop and not run again?

I mean that the timer is working but every player can’t see the other timer working, But we passed this issue together, In my event snip everything is working except the “pause timer”, so the timer keeps running.

Now I linked the timer to a variable for each player and succeeded in stopping the timer for the host. The strange thing is that it did not succeed for the opposing player, even though they were on the same steps. What is also strange is that it actually stopped the timer for the opposing player already, but after the turn returns to him, the timer jumps by several seconds, which is the period that has passed in the game, meaning that it is still working behind, even though the number is fixed on the screen.


the next events are working well for the host

the next event makes the timer stop but the timer is working behind, I don’t know why.


I did the things for the host and succeded, but doesn’t for the player.

Start/reset a timer should be used the first time you start their timer but after that you should pause/unpause. Depending on your events it might make more sense to start/reset and pause the timer in beg of scene, and then later use actions to pause and unpause it where needed.

Also you can just create one scene timer called countingDown. The value will be different for each player, so think of the scene timer as a variable with synch disabled. The players can pause and unpause countingDown and it will only affect the timer in their game, not the others. That will get rid of one piece of complexity where you have to determine which player should pause which timer.

Also where you take ownership in events, try taking ownership of the variables before you change them. That event doesn’t say if you have to be host or not host either, if that matters. It might make sense to find ways to condense everything into one event that works for each player instead of having to change variables back and forth and create these events for player1, those for player2. For instance just keeping the host in charge of the variable of whose turn it is, then in events you can check if the current player is = to the variable of whose turn it is, do all these events and pause the timer.

If I create a scene timer, how will the seconds counter appear on the game scene? Or how can I use it for that? And how do I disable the sync?
Sorry if I’m bothering you.

You’re not bothering me, I just wish I was better at explaining or understanding. But I don’t understand, I thought you were using scene timers already? It looks like you’re using 2 of them.

Here is a quick example using 1 scene timer. It has one text box called playerTurn, this is just to easily show which player turn it is when you test it. It has a scene variable called PlayerTurn. This variable has a default value of 1 so player1 will always go first. It has one scene timer called countingDown. It creates the scene timer in the beginning of scene events, but that is only my preference you don’t have to do it that way. Then it pauses the timer so the timer will not start until the players are ready.

Then the next event block is only for the host (player1). He is in charge of changing variable PlayerTurn and also changing the text box playerTurn. He will either add 1 to PlayerTurn or he will set PlayerTurn back to 1 if PlayerTurn is bigger than the number of players in the game. He will do this by looking at every player’s seconds text and seeing if it reaches 0. I did it that way because I wasn’t sure why you use the timer to count down from 3 to 0 and if you let the timer go past 0 it starts counting up. So I chose to stop it at 0 and end the player turn there.

The next event group is for the player whose turn it is. They can pause or unpause their timer only if it is their turn. I don’t mean for you to have the players pausing or unpausing their tmer, you can change that to your own events, like the click on Start when it is their turn, it unpauses their timer. I am just doing it like that so you can see how each timer only counts for each player.

The next event block just shows what happens when any of the players timer reaches 3 seconds (their second text will show 0 because you have it counting down). I have it start/reset the timer - that is just to put the timer back to 0 (seconds text will show 3) but then pause it so it is not counting down when it is not their turn.

The next event block just shows each players seconds text updating to how many seconds they have left. I use a text object called seconds1 and set ownership to player one, and seconds2 with ownership to player2. I put them a group called SecondsText . Then I check to see which player owns which object in the group and update the text of that object. You do not need a condition of “if seconds text doesn’t equal” etc, It is just my preference.

Anyway this example is not meant to paste into your game to make it magically work. It is just meant to illustrate some concepts so you can see what’s going on better and hopefully figure out where the bug in your project is.

Here are the events and also a json you can get if you want. Then you could open it in GDevelop to preview it in 2 windows and see how the one scene timer is actually a different timer for each player.

1 Like

You are the best helper, and your explanation is clear, I’ll study it and I will follow it,Then I’ll give you feedback, Thank you again and again.

1 Like

Thank you our hero, I succeded and it works good with me.

1 Like

Thank you Lucky-J for this! I was beating my head up trying to figure this out. I got the timer to display on for both my players but something weird is happening with the timer text Object it is moving up on the Y-axis about 10 pixels and I have no idea why.


Any one else experience this issue?

1 Like

Could you start a new thread for this question? And in it include a screen snip of the events that place the timer text on the screen.