How to hide my objectives from another player?

Hi
My game has 2 players, everyone has his objectives that must be hidden from the other, I want to make it a multiplayer game, How can I hide player1 objectives from the other? But the other can hit it without seeing it, My game is a guessing game.

Now I succeed with past issue, But I have another, how to make turns? I mean every player has his turn to shoot, other has to wait. etc.

I would try using shared global variable, where to store which players turn it is. Then conditioning player actions by this variables (if it is not my turn, I can"t do any action).

How can I do that (Using variables to store turns, and if it is not my turn, I can’t do anything)?

First check how to use variables if you are not familiar with that:

Then, when you are using multiplayer game, all global variables are shared across all players (as you can see explained here: https://www.youtube.com/watch?v=6Y5ARM689c4)

So what you have to do is:

  • Create global variable, that would indicate which players turn it is (for example “PlayersTurn”).
  • When players ends his turn you have to store in to this variable whos turn is now and then you can send multiplayer message to trigger actions necessary to start new turn for another player.
  • In the events you will have conditions to limit players actions by variable “PlayersTurn”.
1 Like

I failed, I didn’t find something looks like my target, I didn’t find a variable used to create turns between players, What about Chess for an example? Is there any template for it? I can understand nicely with templets, Chess or any other game has 2 players with turns.

Are you creating multiplayer online or hotseat game?

All the games I found have no turns, also multiplayer games < all players are active at the same time, my game is based on shooting one by one, can anyone prove this with Gdevelop?

What is hotseat game? I’m creating a multiplayer game.

Hotseat = two players playing on one computer.

No, It’s multiplayer with lobby.

Ok, I see - there are actually no examples for multiplayer, it’s brand new functionality in gdev. Anyway aplys the logic I tried to describe higher:

  • Create global var to indicate which player is playing.
  • For the player, that is not playing, create condition to not allow to use control actions over play-board (or elements you don’t want him to control).
  • When actual player is done, he will push button “End of turn” and then change variable of current player playing to next player.

Make sense?

I think I have succeeded, Thank you radekpilmaier, You gave me the first step ( variables).

1 Like

Forgive me, I had an issue with turns again, It worked yesterday, But today doesn’t, these are my events, “player” is a global variable, when it equals 1 the host has his turn to play, when 2 the player2 has his turn to shoot, the first condition works well, the second no, i’m sure that all conditions in it is right, newspirit3 collission with h29, I wonder if is the variable didn’t change to 2 in the first condition. Please help.

Ok, I am also learnin stuff with multiplayer, so let’s try to discover this together :slight_smile:

First method: Owners of variables.
You can set ownership of variables. Only owner can change it and then the value is spread to other players. When you run the game it’s a Host who is owning all global and scene variables, if I’m not wrong.

So what I would try to do as a first thing is, that when player 1 (who is also the host) ends his turn, first change value of current player to “2” and then change also ownership of variable to “player 2”, so he can control it and change its value later. When player 2 finishs the turn, do the same - first change value to “1” and then ownership to “player 1”.

Second method: Sending messages
Then there is another method by sending multiplayer messages. One player sends to all other players message, so they can react on it. Then all variable changes are handled by host, who is reacting to sent messages like “Change player to 1”. By recieving these messages he’s changing the value then.

You can find more details about it here:
https://wiki.gdevelop.io/gdevelop5/all-features/multiplayer/

1 Like

Okay, you are right and I did that, and it worked well, but I faced another issue, like I said my game depends on guessing the position of the enemy’s stuff, He also guess my hidden stuff, so I hid my stuff and shot his land. when I got a target of his stuff like a weapon., I want to see that both of us, succeeded for me, but the event doesn’t seem for him, because I use a condition with a variable that tells the app that the turn is for player one , so other can’t see which weapon he lost…
How to do that? When variable player1 = 1 and the cursor is on (the target) then the left mouse is released.
’ The condition"
A right sign appears at the weapons position, and the weapons picture appears for me, But only for me.

Here is pictures explain that:

This is a next issue now, so please close this issue as solved and open a new one. Also I am bit confused from your description, so try in new issue to follow steps (topics) how to correctly describe what you need.

Hi, I did it with ownership condition, Thank you for your response.

1 Like