- Home /
Question by
johnnieann7 · Mar 07 at 09:08 AM ·
2d gamephotononline game
I tried to make them visible when they are in the same house. or is there a way to get the playerID and target straight to it?
How can we sync a boolean through Photon, I have made the player when he is going into the house, he's disappear to other player who is not in the house but when the other player go in the house, they can not see my player anymore. I tried to make them visible when they are in the same house. or is there a way to get the playerID and target straight to it?
void Start()
{
//OpenDoor = GetComponent<OpenDoor>();
view = GetComponent<PhotonView>();
}
// Update is called once per frame
void Update()
{
//if (view.IsMine)
//{
if (EnterHouse.enterHouse)
{
if (view.IsMine)
{
view.RPC("RPC_toggleVisibility", RpcTarget.Others);
}
}
else
{
if (view.IsMine)
{
view.RPC("RPC_turnOnVisible", RpcTarget.Others);
}
}
[PunRPC]
void RPC_toggleVisibility()
{
Renderer rend = gameObject.GetComponent<Renderer>();
if (rend.enabled)
{
rend.enabled = false;
}
}
[PunRPC]
void RPC_turnOnVisible()
{
Renderer rend = gameObject.GetComponent<Renderer>();
if(!rend.enabled)
{
rend.enabled = true;
}
}
Comment