How can I find and access Local player components using PUN2 in Unity?
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 can I find and access Local player components using PUN2 in Unity?
BHS
2023-02-14 18:40:26
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.
Comments
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.
Tobias 2023-02-17T14:58:16+00:00
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.
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.
Back to top