- Home /
Question by
Aria-Lliane · Aug 20, 2013 at 12:26 AM ·
cameranetworkrpconline game
Assign camera on Online game to character
Hi, I've decided to make on my server-client set up an authoritative server, thus i decided that all Network.Instantiate should be donne by the server, and so every object is owned by the server.
On every single example methods out there that I've found and read everyone uses "networkView.IsMine" to assign the camera to that character, yet on this case it is not applicable. So how can i tell a client "this is your character"?
If anyone knows a working method for this I'd appreciate.
Comment
Best Answer
Answer by Aria-Lliane · Aug 21, 2013 at 12:19 AM
I've found my solution, haven't tested with several Clients yet, but it should work too. This is what I've made:
On Server:
[RPC]
void ImReady(NetworkPlayer player)
{
GameObject spawn = GameObject.Find("PlayerSpawn");
GameObject clone = Network.Instantiate(Resources.Load("Player"), spawn.transform.position, spawn.transform.rotation, 1) as GameObject;
networkView.RPC("thisIsYourChar", player, clone.networkView.viewID);
}
On Client:
[RPC]
void thisIsYourChar(NetworkViewID viewID)
{
NetworkView View = NetworkView.Find(viewID);
if(View!=null)
{
View.gameObject.GetComponent<ThirdPersonController>().enabled = true;
View.gameObject.GetComponent<ThirdPersonCamera>().enabled = true;
View.gameObject.GetComponent<PlayerInterface>().enabled = true;
}else
{
Debug.LogError("NetworkViewID "+viewID.ToString()+" not found, unable to setup camera on character.");
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613112546im_/https://answers.unity.com/themes/thub/images/avi.jpg)