How to handle sending and receiving the state of your game.
Options
I'm working on a 4 player board game where the players have their own stats, and they will be moving across the board for the duration of the game. I have it setup so each player can send stats and that works as intended, but when I try to send out the state of the game to all the players I get issues. Sometimes the state of the game will get sent correctly when it is Player 1's turn, but then when you go to Player 2's turn the game still thinks its player 1's turn or it will skip turns. Also each players turn has multiple states that it can be in.
How would I go about setting up my Unity project to work with sending the state of the game. Do I need multiple Photon Views, just one, or is there another way to do it.
How would I go about setting up my Unity project to work with sending the state of the game. Do I need multiple Photon Views, just one, or is there another way to do it.
0
Best Answer
-
Hi @WizByte_Games,
we don't know much about your game yet except it is turn based and made for four players. Is this a modification from an existing project or a whole new project? If it is an existing project it shouldn't be that difficult to make changes to the existing game logic to make it multiplayer compatible.
If this is a new project, you should make a list of all possible actions a player can do. These actions can be mapped to events for example that can furthermore be used for raising events in order to send turns, moves or game states later.
As you already mentioned the PunTurnManager from the package might be a good entry point for the things you want to have in your game.How much data can be sent at once when a player makes a move?
What kind of data would that be? Sending too much data might result in bad performance on all clients.5
Answers
-
So I figured that I would use the turn manager callback that is included with PUN, but I have a question. How much data can be sent at once when a player makes a move? I need to send the state of the games play area, and some other values to help determine player actions when a turn is being taken.0
-
Hi @WizByte_Games,
we don't know much about your game yet except it is turn based and made for four players. Is this a modification from an existing project or a whole new project? If it is an existing project it shouldn't be that difficult to make changes to the existing game logic to make it multiplayer compatible.
If this is a new project, you should make a list of all possible actions a player can do. These actions can be mapped to events for example that can furthermore be used for raising events in order to send turns, moves or game states later.
As you already mentioned the PunTurnManager from the package might be a good entry point for the things you want to have in your game.How much data can be sent at once when a player makes a move?
What kind of data would that be? Sending too much data might result in bad performance on all clients.5 -
Hey Christian thanks for the reply. I should have explained more about the game as you said. Here a little more detail about my project. This project is a new project that I started from scratch.
- The game is a four player board game where each player gets to take a turn moving across the board.
- Each turn can have multiple phases (Battle, Moving, Shopping, Rebirth, or other evens.)
- During each phase I would need to send what phase of the turn the game is in and a couple of values to tell the other players what is going on during the turn.
- After a player finishes his/her turn the game will move on to the next players turn.
I assume you can only send one move using the send move function per turn. I was thinking of using a hashtable to send the data, but when I tried it said hashtables couldn't be serialized. Even though in the Photon source code there are clearly serialized hashtables.0 - The game is a four player board game where each player gets to take a turn moving across the board.
-
Apparently i have to write this post again because of some random error
Herer is a bit about my game- The game project is made from scratch
- in the game there are four players on a game board.
- each player takes a turn to perform various actions in their turn (Movement, Battle, Shopping)
- Each turn has multiple phases (Start, Rebirth, Movement, Action, End)
0 - The game project is made from scratch
-
So I think i have found a solution to my problem. I shouldn't be trying to push a bunch of data during a certain phase of the players turn. I should just push the data that is important to that phase and then I don't have to have the client and server player keep track of what phase a turn is in just what data was changed during that phase.0