Multiplayer control of all players !

Hello!
I did a multiplayer test that I open the program in two diferent computers , the players appear in the two machines but I m controlling the two player in each machine. All players have controle over the other players at same time.
I m using third person control or first person control scripts and direct connection to test .
What I have to do to control only the player that I conected ?

thanks !

Check the scripts that handle user input. When a player is instantiated, you have to first check if that player is the local player or if it’s a ghost of a remote player. If it’s the local player, then allow your script which handles user input to continue getting the input. However, if it’s just a ghost of a remote player, then you need to disable the input script. Make sense?

The reason you are still controlling all players is because the script for handling input is active on all of the player gameObjects. You need to disable it for anyone other than the local player.

How do I have to do this?
in the examples I see some like this :

GameObject.Find(“Player(Clone)”)…

These is correct ? is the best way for check localplayer ?

How do I have to do this?
in the examples I see some like this :

GameObject.Find(“Player(Clone)”)…

These is correct ? is the best way for check localplayer ?

That has nothing to do with GameObject.Find. Go read about the NetworkView component.

All right I used the condition " if(networkView.isMine)"

Now is working well !!!

Thank you !!!

No problem. The networkView is really important. Also, when you start reading about RPCs, read about NetworkMessageInfo as that is also important.

its obsolete

Hardly surprising for a thread that’s nearly 10 years old!

2 Likes

True