Multiplayer Gameplay – Big Game Project

I have been working on fixing basic multiplayer gameplay this week. What this means is that I wanted to make so two players can join a server, take turns to do actions, update each others hands and what they play. I had a lot of trouble getting the hand to update properly at first and the cards were stacking on top of one another and you had to drag them to fix it instead of it automatically sorting themselves. At first I thought I had some wrong settings in the inspector, but it turned out that all I had to do was call a function called Reposition on the grid of cards whenever the players drew cards.

The next major problem I had, was that old instantiated cards would not destroy when players drew new cards and on the next turn they would have ten cards instead of five. I had made a script called “destroyCard” that would destroy the game object every time a new hand is drawn, but I do not know what went wrong because a random amount of cards would be destroyed every time. Instead I made a script that would destroy all the child objects of a parent object. The cards are part of a game object grid which is the parent of the cards. I would then loop through the children of the grid (the cards) and destroy them one by one.

Then I came to the part which still is not fixed. I do not want players to play simultaneously, but in turns. Right now, the player who joins the server first is the one who gets to go first. At the end of a players turn, I do an RPC (Remote Procedure Call) which should set the second players turn to true and the first players turn to false but these variables will not change for some reason. I have gotten a lot of different errors because I have tried to solve the problem in a lot of different ways suggested by people on the Unity forums. When I think I have solved the problem I get a new error. If this problem persists I may have to try to solve it in a different approach from what I’ve done now, but I do not know how yet and therefore I will have to think about it under the weekend.

cards

Leave a comment