Need help, setting up a 3rd person rotatable camera.

So I have a working version of a 3rd person rotatable camera in single player, but with multiplayer its a different story. The issue I am having is that I need to Initialize a Camera and somehow link it to a freshly initialized player. Since both are freshly initialized I have no clue how to link them together in the unity editors, whereas in single player, both the player and the camera exist before the game is even run, thus allowing pre-linked setups.

This is how I have attempted to tackle the problem. Once the spawnPlayer() method is run, a player will spawn properly and on that player is a ClickToMove script which runs the following:

public GameObject linkCamera; //This is empty and links to cameraPrefab on instantiation.
public GameObject cameraPrefab; //This has the prefab of the camera.
public Transform cameraPos;

void Awake(){
cameraPos = GetComponent ();
cameraPos.position.Set(cameraPos.position.x - 3f, cameraPos.position.y + 3.6f, cameraPos.position.z - 3f);
linkCamera = (Network.Instantiate(cameraPrefab, cameraPos.position, Quaternion.identity,0) as GameObject);
linkCamera.GetComponent ().target = GetComponent();
}

Is there any reason why the camera needs to be instantiated over the network? If not you could just load the camera prefab locally.

That sorta of works, but now I have the issue of when a second player joins, the controls for the first players are suddenly switched and the second camera is instantiated by the newest players feet.

It also appears that the second camera will not follow the newly spawned player.

I’ve tried these to remedy the switched movement issue:
if (!GetComponent ().isMine) {
enabled = false;
}
and

if (GetComponent ().isMine) {
//Move the player to the position
moveToPosition ();
}

anywahn? :frowning:

Nvm I figured it out. Thank you.

How’d you figure it out? I’m having this problem just as you describe it here, “issue of when a second player joins, the controls for the first players are suddenly switched and the second camera is instantiated by the newest players feet.”

Update! Aha, I fixed my issue too. I was being lazy and telling the camera to follow the tag: player. I suppose it was just finding the first object with that tag and following it, but all of my players have the player tag so that was rubbish. Once I properly identified each instantiated player the issue was fixed.