Some troubles with multiplayer. Urgent! Need help!
Hey all I have a problem! I am trying to create a multiplayer FPS (yes fairly generic IKR :P) and I am having some troubles with the multiplayer part of it! I have followed unitys networking tutorial for this sort of think but instead of using the one they created I used the FPScontroller since I had already done some coding of my own and didnt want to restart the whole thing. Story short I could connect and all but when a player connected you would controll both of them from one of the games! Actually the character you where would lock its screen and you would sort of be playing the other player in 3rd person! I have done all the setting monobehaviour to network behaviour and done everything right but I am stuck in a tight spot here and need some urgent help! Anyone here think they could help me figure this one out??
Thanks - Ethan
Answer by ITZZZETHAN · May 03, 2017 at 01:03 PM
maybe photon will help? I do not know how to use that though
Answer by OfficialCoatsee · May 07, 2017 at 02:48 AM
If you do use photon networking (i'm not too sure about unity networking) you on the loading of the game, once the player is spawned - you can enable certain scripts attached to the player by doing a check to see if the player is yours or not.
For instance:
void OnJoinedRoom() {
GameObject player = (GameObject)PhotonNetwork.Instantiate (playerPrefabName, spawnPoint.transform.position, spawnPoint.transform.rotation, 0);
player.GetComponent<MovementControllingScript> ().enabled = true;
minimapcam = player.GetComponent<PlayerSettingsScript>().minimap_camera_object;
minimapcam.SetActive (true);
}
As I mentioned - this would be for Photon Networking, but if you are spawning players through Unity Networking already, you should still know how to Enable or Disable components.
Your answer
![](https://koobas.hobune.stream/wayback/20220612121211im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Adapt the FirstPersonController Script to Multiplayer 0 Answers
Unet: Is the position in a GameObject Inspector hierarchy important 0 Answers
Second button works 4 times 1 Answer
how can i use my phone's camera as a webcam and let unity recognize it as a connected webcam? 0 Answers
Multiple mobile devices 0 Answers