- Home /
Update int value with photon rpc?
Example scenario: the room is set up and the scene starts when the actors are ready. I have an int value called x, I increment x by 1 when players click a button. When all 4 players press this button, the x value reaches 4. And if the number of players in the room and the x value are equal, I load a new object on the stage. I thought I should do this with rpc but failed. i am sending you my code file:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice;
public class kontrolonline : MonoBehaviourPunCallbacks
{
public int x;
public void one()
{
photonView.RPC("KacOldu", RpcTarget.OthersBuffered, x);
KacOldu(x);
if (PhotonNetwork.CurrentRoom.PlayerCount == x)
{
GameObject izle = PhotonNetwork.Instantiate("webview", Vector3.zero, Quaternion.identity, 0, null);
}
}
[PunRPC]
private void KacOldu(int x)
{
x=+ 1;
Debug.Log("?",x);
}
public void Start()
{
kaç = 0;
// GameObject kaç = PhotonNetwork.Instantiate("kaç", Vector3.zero, Quaternion.identity, 0, null);
}
}
Result : the value of x does not increase by 1 when the player clicks the button. So x is never equal to the number of players in the room. Where do you think I went wrong, could you please tell me?
Is the function one
being called correctly?
Are there any errors?
Your answer
Follow this Question
Related Questions
Photon RPC problem... 3 Answers
PhotonView with ID has no method marked with the [PunRPC](C#) property! BUT IT HAS ??? 1 Answer
Problem with animation RPC in Photon 1 Answer
RPC and inheritance 1 Answer
RPC Player Name and show it above head 0 Answers