The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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