Skip to main content
make updated code more prominently
Source Link
Banana
  • 243
  • 2
  • 10

TheCurrently, the best method is using NetworkClient from Mirror:

using Mirror;
GameObject localPlayer = NetworkClient.localPlayer.gameObject;

Note that the following is deprecated and shouldn't be used.
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;

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;

Currently, the best method is using NetworkClient from Mirror:

using Mirror;
GameObject localPlayer = NetworkClient.localPlayer.gameObject;

Note that the following is deprecated and shouldn't be used.
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;
updated because old code is deprecated
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61

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;
 

New Method 2021: Note that in more recent development, one should use NetworkClient from Mirror instead:

using Mirror;
GameObject localPlayer = NetworkClient.localPlayer.gameObject;

The new method uses the NetworkClient from Mirror

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;

New Method 2021:

using Mirror;
GameObject localPlayer = NetworkClient.localPlayer.gameObject;

The new method uses the NetworkClient from Mirror

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;

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;

New Method 2021:

using Mirror;
GameObject localPlayer = NetworkClient.localPlayer.gameObject;

The new method uses the NetworkClient from Mirror

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;

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;

New Method 2021:

using Mirror;
GameObject localPlayer = NetworkClient.localPlayer.gameObject;

The new method uses the NetworkClient from Mirror

Source Link
Banana
  • 243
  • 2
  • 10
Loading