Client sees 3 players while they are actually 2 players in the room

Hello everyone! I've never went through this but when i host a room from a game window and join the room from another window, the person who joins sees 3 players when they are actually 2 players included the player who joined, so what is causing this to happen? is there any problem with my code or is something wrong from the photon side? Here is my instantiate code:

//The script which handles the Multiplayer Game related stuff!

using System;
using UnityEngine;
using Photon.Pun;
using Random = UnityEngine.Random;

public class GameManager : MonoBehaviour
{
    [Header("Player Instantiation")]
    [SerializeField] private GameObject playerPrefab;

    private void Start()
    {
        PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(Random.Range(-5f, 5f), 1.5f, Random.Range(-5f, 5f)), Quaternion.identity);
        Debug.Log("Successfully loaded game!");
    }
}

This is the one which should instantiate the Player but why is the client who just joined seeing 3 Players when there should actually be 2 Players, is any duplicate instantiation is happening or what? Feel free to mention me if you all want any extra details about any other scripts or scene.


Thanks in Advance!

Best Answers

  • IBX00
    IBX00
    Answer ✓

    Can you share the screenshot of your hierarchy of the game where there are 3 players? Also, share screenshots of the photon view components of all the players.

  • Tobias
    Tobias admin
    Answer ✓

    The Master Client will have ActorNumber 1 and it's viewIDs are in the range of 1001 to 1999. Two of the characters are instantiated by the Master Client.

Answers

  • Also this should make you understand what is happening


  • hello brother where are you from

  • I'm from India

  • Anyone there?

  • IBX00
    IBX00
    Answer ✓

    Can you share the screenshot of your hierarchy of the game where there are 3 players? Also, share screenshots of the photon view components of all the players.

  • IBX00
    IBX00

    @Saharsh1223 Btw, where are from, I mean in India

  • @IBX00 Sorry for the very late response, here is a screenshot of the client "Saharsh1" joined the room:


    And here is the host's duplicate spawning in and even the real host's name is also "Saharsh2":


    And this is the real synchronising host "Saharsh2" (not the duplicate one)


  • @Saharsh1223 It's fine, thanks for sharing the screenshots. So there are 2 masters and 1 host, as the view Id suggests. Am I right?

  • Tobias
    Tobias admin
    Answer ✓

    The Master Client will have ActorNumber 1 and it's viewIDs are in the range of 1001 to 1999. Two of the characters are instantiated by the Master Client.

  • @Saharsh1223 Sorry for the late reply. Have you solved the issue? If not, can you share your project (as a package) because I've failed to replicate the issue? Even with your shared code.

    If yes, what was causing it?