Hi I’m new to multiplayer in unity.I looked some code up but they didn’t work I have my network manager and it spawns different clients.I need to send a Message from one of my gameobjects to the clients.
if (GetComponent<NetworkIdentity>().isLocalPlayer)
{
playerId = GetComponent<NetworkIdentity>().netId.ToString();
}
By the above code I can distinguish each running instance of the game.So each games knows it’s player and saves it’s id in Player.cs.
from another gameObject I can use
players = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject player in players)
{
if (player.GetComponent<Player>().playerId == "1")
{...
so now first client can do things.Till it’s over then I want to send a message from the current gameobject to another client this time to another instance of the game so I need server and client code for that and receive it from the client to the current GameObject.