Weird bugs on client when there are two players

Hi! I've been working on a tabletop videogame for quite some time now, and i just changed something: before, the board wasn't instanciated, and was just here when i loaded the game scene. But i decided i needed to instaciate it for diverse reasons, and now it does some weird things...
Basically, in the game, you can select a square on the board, and it makes a little arrow on top of it to say it is selected. When another is selected, it gets disabled and enabled on another square. Anyways, when there are two players in the room, my client keeps not disabling certain arrows (and thus, not unselecting squares) making it multiple cases selected! but as soon as one player leaves the room, all arrows disapear except the latest one... Weird, isn't it?
Here are the part of codes which are essentials:
Case.cs, which is basically "Square.cs", but in french:
   void Update()
    {
        if (isSelected)
        {
            arrow.SetActive(true);
        }
        else
        {
            arrow.SetActive(false);
        }//Pretty straightforward, even though not optimized
Then, PlayerController, which does the raycasting on which case you clicked on:
if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.gameObject.CompareTag("Case"))
                {
                    Case caseHit = hit.transform.GetComponent<Case>();
                    if (canChangeSelection)
                    {
                        foreach (Case c in GameManager.Instance.cases)
                        {
                            if (c.caseNumber == caseHit.caseNumber) //On a retrouvé la case sur laquqelle on a cliqué dans l'array
                            {
                                Debug.Log(caseHit.caseNumber);
                                if (caseSelected != c.caseNumber && caseSelected != -1)  //Si la case sur laquelle on a cliquée n'est pas celle selectionnée
                                {
                                    caseHit.isSelected = true;
                                    GameManager.Instance.cases[caseSelected].isSelected = false;

                                    caseSelected = c.caseNumber;
                                }
                                else if (caseHit.isSelected)
                                {
                                    caseHit.isSelected = false;
                                    caseSelected = -1;
                                }
                                else if (caseSelected == -1)
                                {
                                    caseHit.isSelected = true;
                                    caseSelected = c.caseNumber;

                                }
                                UpdateSelection();
                            }
                        }
                    }
                }
sorry for the french commentaries, i didn't quite get rid of my old bad habits lol

Comments

  • I pressed "Post"Without thinking, sorry!
    Wanted to add few things:
    - of course, the square selection is ClientOnly, you can't select squares for your oponent... But i am forced to instanciate with photon, am i not?
    - SO i am forced to have a photonView, am i not?
    - and i just wanted to say thank you for reading this far too, and even more if you're going to help me :)
  • Update: The answer to my first question was no! i instantiated them normally and it works perfectly well! sorry for bothering!