Guys, i used first person controller prefab for each user who gets connected in my multiplayer game. And used Network.Instantiate(prefab…) and ofcourse, the prefab gets spawned in each player, but since camera and mouse controls are attached to that prefab, any player can control any player. I get “2 Audio Listeners found”. Ofoucrse its fine…but i used a script to control this like
function Awake () {
if(networkView.isMine)
{
GetComponent("FPSWalker").enabled=true;
GetComponent("MouseLook").enabled=true;
}
else
{
Destroy(gameObject.FindWithTag("MainCamera"));
}
}
Still i face lot of problem like my camera is deleted instead of oponents camera. Whats the problem?? How to instantiate a player prefab in network?? Plz help!!
Use Transform.Find instead.
Please enlighten me more…My actual problem is in my multiplayer game, im using first person controller(FPC) prefab for each client. So, when more than 1 client joins the game, more than 1 FPC prefabs are instantiated in each client, since each prefab has a camera and mouse look script attached to it, unity reports multiple audio listeners and when there is any keyboard arrow key movement, all users are moving…!!!
PLZ help!
I don’t see the difficulty. Disable them !
Either all components are enabled by default, in the prefab, and you disable them all if networkView.isMine == false…
Or all components are disabled by default, and you enabled them all if networkView.isMine == true.
Plus, each prefab has his own gameObject called MainCamera, right ? By using transform.Find, you limit the search (for a gameobject called “MainCamera”) in the hierarchy of the transform (only his children are being checked).