RPC UI TEXT

I am creating a Fighting game where when a player hits another player the UI TEXT(Points) will increment.
How am i going to implement that?
I know that i will create variable for points and it will increment when another player hitted. but how am i going to update the point on the player 1 screen and player 2 screen.

0 - 0
P1 P2

that should be the output and it should be updated on both player’s screen. Please Help :smile:

You can make two variables called player1Points and player2Points and add a SyncVar attribute before both of them. If the server changes the value, it will be changed on all clients. In your case, I would add a hook to the syncvar and inside that hook, also call a function to change the interface!

Try something like this:

    [SyncVar(hook = "DisplayText")] private int speed = 0;

   
    void Update(){

        if(isLocalPlayer){

            if(Input.GetKeyDown(KeyCode.Space)){

                CmdSpeed ();
            }
        }
    }

    [Command]
    void CmdSpeed(){

        speed += 10;
    }

    void DisplayText(int spd){

        speed = spd;

        if(isLocalPlayer){

            GameObject.Find("Player1").GetComponent<Text>().text = speed.ToString();
        }
       
        else{
           
            GameObject.Find("Player2").GetComponent<Text>().text = speed.ToString();
        }
    }