0

I am trying to understand data synchronization in Unity network development. First Problem that I am facing is to understand unity3D server client model.

1

  • My basic understand is that one machine behaves as server + client and other simply client.
  • But in following graphics when hosted from PC build there is no server at all????
  • When I host it from Unity Editor now there are both server + Client.. why???

2

  • The other problem I am trying to solve that is to make such a behavior in which if I press space button at server it increments the server score.

  • Same goes to client when space is pressed at client it increment the client score.

  • No progress at all because I am unable to figure it out how to separate the server date from client data. Trying to get the reference of two different Text objects if it is server it gets the server text from hierarchy and if it is client make it to get the client text object from hierarchy.

I hope Graphics are self self explanatory.

Following Graphics are consist of 2 different problems I am facing.

Bilal Mirza
  • 233
  • 1
  • 3
  • 14

2 Answers2

1

When you host from standalone builds you can't see who's the host directly in inspector on client. You can create UI to display information about network identity and make sure everything is correct.

Fiffe
  • 1,196
  • 2
  • 13
  • 23
1
  1. for the first question, remember:

When you Join game as a Host You are Server + Client

When you Join game as a Server you are only server.

When you join game as a Client you are only client

You check these thing in build and develop your OWN GUI to view the checks as you mentioned.

  1. Yes you can differentiate client and server using these checks

    if(isLocalPlayer){

    //yes this is the local player //The class must be derive from networkBehaviour to access this property }

and You can also use Network class to check is Server.

Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186