FPS context.When a client connects to host , both runs have hosts camera pov

Using a server , client nr.1 outputs client’s nr.2 pov, yet each client controls his own player clone .plz help )

9751036–1395568–PlayerMovement.cs (1.86 KB)
9751036–1395571–CameraLook.cs (1.09 KB)

You must have a camera in the player prefab and none in the scene. Mark the camera component as unchecked (disabled) and enable it only if (IsOwner) in OnNetworkSpawn.

1 Like

Alternately you can just assign the main camera within a NetworkBehaviour.OnNetworkSpawn method only for the owner of the player object:

A very simple example:

public class PlayerCamera : NetworkBehaviour
{
    public override void OnNetworkSpawn()
    {
        if (IsOwner)
        {
            // Just as an example, you can parent the main camera under the owner of the player during spawn
            Camera.main.transform.parent = transform;
        }
        base.OnNetworkSpawn();
    }
}

The idea being that the only time the script within the “if (IsOwner)” check will be invoked is when it is run on the local instance of the player assigned to the local client.

1 Like