Hello everyone!
I bought this product yesterday since a need to sync my characters gear over the server
was something I could not satisfy with the in-built network function that came with unity
(I need to sync which children are active, and which are not. I have no other way
of displaying gear unfortunantly)
Anyway, I had a camera system that worked just fine with the old Unity networking, but
for some reason it no longer works with TNet.
The way I do the camera is that I have the camera in the level already
then when a player joins the level the camera gets his
"LookAtSpot" (A gameobject thats a few pixels to the right of the characters head to make
the camera look over the players shoulder instead of the back of the head).
The code I used to use, and the code I'm using now;
(localPlayer is just a bool value)
Current code:
if(TNManager.isThisMyObject)
{
localPlayer = true;
tempCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<HackAndSlashCamera>();
tempCam.LookAtTarget = GameObject.Find("LookAtSpot");
}
else
{
Name = "Remote" + TNManager.playerID;
name += Name;
CharacterController tmp = GetComponent<CharacterController>();
tmp.enabled = false;
AdvancedMovement tmp2 = GetComponent<AdvancedMovement>();
tmp2.enabled = false;
//HackAndSlashCamera tempCam = GetComponent<HackAndSlashCamera>();
//tempCam.target = null;
}
Old in-built unity net code:
if(networkView.isMine)
{
localPlayer = true;
}
else
{
Name = "Remote" + UnityEngine.Random.Range(1,10);
//Name = "Remote" + count;
name += Name;
AdvancedMovement tmp2 = GetComponent<AdvancedMovement>();
tmp2.enabled = false;
//HackAndSlashCamera tmp5 = GetComponent<HackAndSlashCamera>();
//tmp5.enabled = false;
//networkView.RPC("askName", networkView.viewID.owner, Network.player);
}
Now, the problem is that though it works fine if you're the first player to connect
if you're the second player to connect, you see the same thing the first player
see's meaning, that even though your character is instantiated just fine
the camera does not change to the correct player.
Meaning that every player that joins after the first one, will all look
at the exact same thing the first player looks at.
I dont know how to fix this, hopefully someone can help.
If you need to see the camera script, please do say so.
~Etarnalazure