How can I find and access Local player components using PUN2 in Unity?
Options
Hello,
I have 2 scripts 1: Player and 2: Game Manager, both spawn when the game starts.
Since each player will be spawning the same 2 objects (player and game manager) when the game starts... How can I get the local Player script on Game Manager Start function?
I tried this method:
But it sometimes works and sometimes returns Null Reference error and breaks my game.
0
Answers
-
Those scripts are both part of a prefab with a PhotonView on it?
Each script can refer to the PhotonView on the same GO to figure out if
IsMine
is true.0 -
No, They are not part of the same prefab, My Spawner script instantiates both the Player prefab and Game Manager prefab (both has their own Photon Views) when the game starts.
0