Hello everyone,
So today I tried multiplayer for the first time (I’m a noob in that by the way), so I used unity’s basic multiplayer assets and followed this guys tutorial:
Everything works fine except my friend and I share the same controller. How can I make it so everytime someone connects, it spawns a different controller. Thanks.
void OnConnectedToServer()
{
GameObject clone = Network.Instantiate (cubePrefab, position, rotation, 0);
clone.AddComponent("PlayerControlScript"); //this script controls movement
//Make your camera follow clone here
}
Make sure the “cubePrefab” only has the physical part of the character (mesh, colliders, etc) and a networkview observing the Transform component. Make sure there are NO cameras in the prefab.
This will give you a non-authorative server game where two players can see eachother.