Problem with using TagObject
Options
skokon
✭
Hello, im using TagObject to define my gameObject, the problem is that photon cloud returns normal object not the gameobject and im trying to convert it to gameobject like this way
(GameObject)photonPlayer.TagObject;
im getting this error
InvalidCastException: Cannot cast from source type to destination type
.
0
Comments
-
Hi @skokon,
can you please show the code when you set the TagObject and the entire code line when you try to access it?
As a reference:PhotonNetwork.player.TagObject = gameObject; GameObject go = (GameObject)PhotonNetwork.player.TagObject;
The first line will store a reference to the GameObject this script is attached to, the second will access the stored reference and I would be able to do something with it afterwards. I also don't get any InvalidCastExceptions when using this code.0