How to pass a value to the instantiated object?

Options
The master-client object passed random "playerID". Other clients do not get "playerID" in their objects. Tried directly, tried via the function argument with PunRPC attribute (using PUN2).
All of those objects have PhotonViewer, their transforms sync and driven. Now just need to assign them "playerID" & tag.

Code:
using UnityEngine;
using Photon.Pun;
using System.IO;

public class PhotonPlayer : MonoBehaviourPun
{
    public PhotonView PV;
    public int playerID;
    public GameObject myUnit;
    
    public void Start()
    {
        PV = GetComponent<PhotonView>();
        playerID = Random.Range(0, GameSetUp.GS.spawnPoints.Length);

        if (PV.IsMine)
        {
            myUnit = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "UnitAvatar"),
            GameSetUp.GS.spawnPoints[playerID].position,
            GameSetUp.GS.spawnPoints[playerID].rotation, 0);

            PV.RPC("RPC_ID", RpcTarget.AllBuffered, playerID);

            //myUnit.GetComponent<UnitSetup>().playerID = playerID;
            //myUnit.tag = "Player" + playerID;
        }
    }

    [PunRPC]
    public void RPC_ID(int ID)
    {
        myUnit.GetComponent<UnitSetup>().playerID = ID;
        myUnit.tag = "Player" + ID;
    }
}

Comments