Totally SOLVED how to get photon view or game object of owner
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).
Totally SOLVED how to get photon view or game object of owner
cherrybombe
2017-09-17 13:58:50
Hi
i have an scene object and i want to be able to get the game object of the current owner - is this possible? i ve searched for hours with no success.
thanks in advance for the help
Comments
cherrybombe
2017-09-17 15:59:18
partially solved
if anybody else needs this - only seems to work with
PhotonNetwork.player.TagObject
Instantiate
GameObject pl = PhotonNetwork.Instantiate (playerprefab.name, spawnPt.position,spawnPt.rotation, 0) as GameObject;
pl.GetComponent().owner.TagObject = pl;
to get the game object of the owner
PhotonPlayer p = photonView.owner;
GameObject pp = p.TagObject as GameObject;
even when p does not return null, owner.tagObject returns null every time
Any ideas why tagObject doesn't work like this?
cherrybombe
2017-09-17 21:01:07
i misunderstood how tag object works,
make sure you set owner.tagobject from void Start() on a script on the photon view and not during PhotonNetwork.Instantiate
this works:)
Back to top