The new multiplayer API exposes a isLocalPlayer boolean which is useful for checking if the script is being ran on the local player.
Is there anything in the API to get the local player’s game object?
I see PlayerController in the docs which has a reference to the gameobject, but I don’t know how to retrieve this component.
I also see playerControllerId on various components, but no example for retrieving the PlayerController with this.
I know that I can name the local player’s game object and retrieve it using Find or even better tag the local player’s game object and retrieve it using FindGameObjectWithTag.
But is there a better way through the Networking api?
I like to use the override, OnStartLocalPlayer, which will only be called on NetworkBehaviours on the local player object (and then cache a reference to the gameObject as needed).
Did you drag & drop a NetworkManager into your scene ?
Do you use your own NetworkManager and have made your own Awake function ? That kill the singleton too