How to get a client ID?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
How to get a client ID?
lennart862
2017-08-04 01:43:21
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
[Deleted User]
2017-08-07 08:10:11
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
PhotonNetwork.player.ID
only returns the ID of the local client, so using this would end in an unwanted behaviour.