I'm using Mirror as UNet is deprecated. How can I get the local player GameObject in my code?
The ClientScene class has a static property called localPlayer of type NetworkIdentity. All Components in Unity have
gameObject as property which refers to the GameObject they're attached to.
So in order to get the localPlayer object you would do:
using Mirror; GameObject localPlayer = ClientScene.localPlayer.gameObject;
Note that in more recent development, one should use NetworkClient from Mirror instead:
using Mirror; GameObject localPlayer = NetworkClient.localPlayer.gameObject;