How to get a client ID?

A very simple question: I have a script on an instantiated game object and I want something like this:

public int GameObjectOwnerID;

void start()
{
GameObjectOwnerID = PhotonNetwork.player.id;
}

The player id is the same id you get if you receive an event by PhotonNetwork.RaiseEvent. If you receive the event you get the senderid which you can use for conditions etc... Thank you in advance!

Comments

  • Hi @lennart862,

    if this game object gets instantiated through PhotonNetwork.Instantiate, it has an attached PhotonView component. Using this you can get the ID you are looking for: GetComponent<PhotonView>().ownerId

    PhotonNetwork.player.ID only returns the ID of the local client, so using this would end in an unwanted behaviour.