How to I make a Death Counter?

Hey,
I’m working on a 2d game where two sprites try to kill each other by pushing them off a platform. After one dies, they return to their starting position. I would like to make a GUI Text that tells how many times each person has died. I’m unsure of how to go about doing this. Whats the best way to (c#) script this?

1 Answer

1

Check out GUI.box Unity - Scripting API: GUI.Box

int deathCounter;
    
    Update(){
       if(){
          deathCounter++;
       }
    }
    
    void OnGUI(){
       //Draws out a box on position x and y, with a specified width and height and width.
       GUI.Box(pos.x,pos.y,width,height,deathCounter.ToString());
    }