problem with synchronization .SetActive() between two players

Hello, i made rooms in house which will be activated if player enter house (and hit trigger collider) and if he leave, the rooms will be deactivated
but problem is, when player1 is in house and player2 leave the house, these rooms will be deactivated for everyone and i tried to fix it with this code but it still doesn't work

- player is instantiated prefabs
- it only works for one player...
using UnityEngine;
using Photon.Pun;

public class LoadHouseRooms : MonoBehaviour
{
    public PhotonView PView; 
    public GameObject rooms;

    void OnTriggerExit(Collider detection)
    {       
         if (detection.gameObject.CompareTag("player"))
         {
            if (PView.IsMine)
                rooms.SetActive(true);
            else
                return;
        }
    }
}

Sorry for my low english skillz and thanks in advance




Comments

  • you need something to check how many players are in the house before activating rooms. (when it becomes 0)
Sign In or Register to comment.