• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by asalas77 · Mar 25, 2016 at 05:50 PM · multiplayerrpcclientturn-basedid

Managing turns in online turn-based multiplayer game using Unity Networking

I am developing a turn-based online multiplayer game. I got to a point where I need to manage which player takes its turn. The way I though to do this would be to have clients manage finishing your own turn and server managing starting turn for players. Im my mind this could be achieved by having a state machine running on the server that loops through all the players and notifies them when they are to make a move.

So the desired game flow would look like this:

  1. Player makes a move

  2. Player clicks a button "End turn" and is not allowed to take any more action( e.g. by setting a false flag somewhere)

  3. This runs a server command saying "Hey, a turn just ended" (with no need to specify which player ended his turn)

  4. The next player from the list id notified it's his turn. Now this is the part I need help with. I can see this handled different ways:

    a. Server sends a message with active player id to all clients. Clients then check to see if the id is theirs, and one of them takes turn. This allows all clients to do stuff like highlighting active player, but requires an active client to recognize itself from the id.

    b. Server sends a message to one specific client. Other clients don't know who takes turn, only if it's if them someone else. This requires sending a message to a specific client.

    c. The state machine is running on clients, not on the server. Server only takes in a endTurn() command from one of the players and broadcasts it to the other ones. Clients then handle turn management themselves. Server doesn't know which player takes turn.

It seems to me that a is the best, but how can I distinguish clients? Is there some sort of network-wide ID system I can use or do I have to write it myself?

If there's a better way to implement this, please tell me how.

Also, is there a way for the server to call a method on one specific client? (not all at once) If so, how do I do it?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Using .SetActive() over Unity Network for multiplayer. (Enable weapons on clients) 1 Answer

Requesting data from server 1 Answer

Help with Unity photon multiplayer turn base fighting system. 1 Answer

Array of NetworkViewID passing in a RPC 1 Answer

Sending info to/from different networkViews 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges