- Home /
Why when I make a Networking first person game it controls the other person?
So i have been trying to figure out how to make a networking first person shooter for a while now and im getting closer. I now have a menu that asks you to connect, then once you connect it creates you in the game. But my problem is when the second person joins, it switches the controls to where the person on computer 1 will control the person on computer 2 and same for the other way around. Can anyone think of why this is happening?
Answer by softrare · Dec 28, 2012 at 07:12 PM
That happens because you probably don't make a distinction between local and remote player. The local player has all the movement scripts. The remote player only looks like the local, but does not have movement scripts attached to it (certainly does not answer to key strokes). So when you instantiate the remote player (the player which is not the one which should be controlled by the local keyboard, but a remote human) don't have it scripts attached which listen to key strokes, and make sure it is properly synchronized across the network.
So what can i do to fix this? Im pretty new to networking.
Read this document: http://download.unity3d.com/support/resources/files/$$anonymous$$ultiplayerTutorial.pdf . As said, make 2 player prefabs, one which has scripts on it, that syncronize it over the network (the remote player), and one which is controlled by keyboard, this one is the local player. Depending on the situation you instantiate one or the other. The document should make it pretty clear.