For my multiplayer game, I use a modified version of the FPS Input Controller script which adds this to the beginning of the update function:
The problem is, when I run a client which joins the server, it ends up controlling the other character. How do I fix this?
Lost hours of trying to solve this problem myself.
For now it seems I have a working solution - at least for my testproject
Inherit class FirstPersonController from NetworkBehaviour (needs using UnityEngine.Networking;)
In Start() only do all initialization “if (isLocalPlayer)”
In the else-Branch put:
GetComponentInChildren<AudioListener>().enabled = false;
GetComponent<CharacterController>().enabled = false;
This line can also help:
Debug.Log(“Start():” + this.GetComponent().netId + ", " + his.GetComponent().name + ", " + isLocalPlayer);
In Update() and FixedUpdate() also everything into a “if (isLocalPlayer)”
Add Network Identity to your FPSController, and check Local Player Authority
Add Network Transform to your FPSController. I think SyncMode Sync Transform is the correct one
But I’m still a newbie on unity, so use with caution.