#Ahh. I don't understand why that is the

1 messages ยท Page 1 of 1 (latest)

cursive urchin
#

You can have your exact setup with 0 player objects.

#

Where the Host is a client and hosting the server + another client connects to the server.

#

That means we have the Host as connection 0 and the client as connection 1.

#

Let's say we had 1 object in the scene, GameManager

#

There will be an instance of the GameManager object on the Host's screen, and one on the Client's screen

celest vigil
#

Yes

cursive urchin
#

If we call an RPC marked SendTo.NotServer from the Host's GameManager object, it will be sent to the Client's GameManager object

#

I see you're using PlayerNetwork and putting it on each player object, which I think is causing your confusion

celest vigil
cursive urchin
#

You're calling an RPC marked SendTo.NotServer on the Host's Player Object, and expecting it to be received on the Client's Player Object.

#

It will be received on the Client's version of the Host Player Object.

celest vigil
#

Oh

#

I see

cursive urchin
#

Which is why I would put this logic on an object/script called something like ConnectionManager

#

and use the ulong from NetworkManager.Singleton.OnClientConnectedCallback

#

and pass it through your RPC

#

to tell clients who just connected using the ulong ID.

#
[Rpc(SendTo.NotServer)]
    void UpdatePlayerCountRPC(int playerCount, ulong playerConnectedID)
#

something like that

celest vigil
#

I'm aware of NetworkManager.Singleton.ConnectedClientsIds exists, I just wanted to use some data and pass it around ๐Ÿ™‚

#

Thanks for the help

cursive urchin
celest vigil
#

So is it possible to send data to clients Local Players from the server, in the way I am intending?

cursive urchin
#

Yep!

celest vigil
#

Hmm is it via RPC with ulong ID by any chance ๐Ÿ˜„

cursive urchin
#

Sending an RPC to a specific connection can be done with SendTo.SpecifiedInParams

#

You can also do this when working on Player Objects:

[Rpc(SendTo.NotServer)]
private void LocalPlayerObjectRPC()
{
  if (!IsLocalPlayer) return;

  // Tell the local player to run some code on their player object
}
#

Technically a waste of bandwidth, but ๐Ÿคทโ€โ™‚๏ธ

#

Not the biggest deal in the world.

sudden vine
#

There are RPCTargets you can use as well

Any process can communicate with any other process by sending a remote procedure call (RPC). As of Netcode for GameObjects version 1.8.0, the Rpc attribute encompasses server to client RPCs, client to server RPCs, and client to client RPCs. The Rpc attribute is session-mode agnostic and can be used in both client-server and distributed authority...

cursive urchin
#

Also allows you to run code for other clients before the return statement