Skip to content

Instantly share code, notes, and snippets.

@SocketWeaver
Created June 16, 2019 23:05
Show Gist options
  • Save SocketWeaver/774c3e8789635832f0a3e02ab7fc04d5 to your computer and use it in GitHub Desktop.
Save SocketWeaver/774c3e8789635832f0a3e02ab7fc04d5 to your computer and use it in GitHub Desktop.
Camera follows the local player
NetworkID networkID;
void Start()
{
characterController = GetComponent<CharacterController>();
animator = GetComponentInChildren<Animator>();
player = GetComponent<Player>();
networkID = GetComponent<NetworkID>();
// set the camera's target to the local player
if (networkID.IsMine)
{
CameraFollow cameraFollow = Camera.main.GetComponent<CameraFollow>();
cameraFollow.Target = transform;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment