I am trying to sync the points so when a player collides with an object they get a point. The problem is it does not update on the other players screen when that player gets a point. I've been trying to sort this code for a while but can't figure it out how to make it work. Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Pun;
public class FlagPoints : MonoBehaviour
{
public TextMeshProUGUI text;
public TextMeshProUGUI text2;
private GameObject Flag;
PhotonView PV;
public static int points = 1;
private int CurrentScore = 1;
public string tagToCompare = "Floor";
void OnTriggerEnter(Collider col)
{
if (col.transform.tag == tagToCompare)
{
Debug.Log("It works!");
if (PhotonNetwork.IsMasterClient)
{
if (PV.IsMine)
{
PV.RPC("DisplayScore", RpcTarget.All, text);
}
Destroy(Flag);
}
else
{
if (PV.IsMine)
{
PV.RPC("Display2ndScore", RpcTarget.All, text2);
}
Destroy(Flag);
}
}
}
[PunRPC]
void DisplayScore(int CurrentScore)
{
text.SetText("points:" + CurrentScore++);
}
[PunRPC]
void Display2ndScore(int CurrentScore)
{
text2.SetText("points:" + CurrentScore++);
}
}