- Home /
Multiplayer - all players respond to same input
I am working on making my game multiplayer, and I have the server working, I can connect with clients, and everything works fine, except for one thing...
All of the players are responding to input. I can start a server, connect with two clients, and the player units from both clients will move in unison to input from either client.
I'm pretty sure this is a common problem to people learning networking; anyone know what I'm doing, without me having to post a huge chunk of networking code?
Answer by flamy · Mar 12, 2012 at 06:06 AM
ofc it is the common issue with everyone who starts learning networking...
all you have to do is add this condition where you check for input.
if(networkView.isMine)
For example:
function update() {
if(networkView.isMine) {
// handle input here!!!
}
}
or you can do it the other way also
function Start()
{
if(!networkView.isMine) { enabled=false; } }
Perfect! I knew it had to be something simple like that; thanks for the quick response.
One more thing...
$$anonymous$$y movement is now showing across all clients, but these player objects are sprites, shifting textures to simulate animation.
The sprites only change in their own NetworkView. In the other clients, you can see the movement, but the sprites never change.
Never$$anonymous$$d, I figured it out. I wasn't understanding what was going on with the OnSerializeView function, but I got my head around it now.
Your answer

Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Camera attached to the wrong player 1 Answer
How to call a function from another script? 1 Answer
Turn based multiplayer problem 2 Answers