Hello, I'm trying to get a variable that is player specific that, when that specific player does something, it modifies only that player's variable. I believe the best way is a RPC and I'm unsure whats not working here. The code is working as intended until I try to modify it based on a specific player. I would like to note that I'm not trying to get a specific group of people, but rather 1 specific person.
void rest(){
if (sleeping == true && sleepbar <= 100) {
transform.GetComponent<PhotonView> ().RPC ("resting", PhotonNetwork.player, decrease);
}
if(sleeping == false) {
transform.GetComponent ().RPC ("notsleeping", PhotonNetwork.player, decrease);
}
}
[PunRPC]
public void notsleeping( int amt){
sleepbar -= amt;
}
[PunRPC]
public void resting( int amt){
sleepbar += amt;
}
void rest(){
if (sleeping == true && sleepbar <= 100) {
transform.GetComponent<PhotonView> ().RPC ("resting", PhotonNetwork.player, decrease);
}
if(sleeping == false) {
transform.GetComponent ().RPC ("notsleeping", PhotonNetwork.player, decrease);
}
}
[PunRPC]
public void notsleeping( int amt){
sleepbar -= amt;
}
[PunRPC]
public void resting( int amt){
sleepbar += amt;
}