Hello Unity I am trying to make a end screen for my split screen game how would I do this?

I have spent hours trying and nothing to show for it. For starters I have two players each with there own prefabs and scripts for movement and health. I am trying to make it where if one player health equals zero a UI image will pop on the screen declaring which player has won. How would I go about doing this so far I have been trying to if functions but that has not work so far I can not figure out if you can cross scripts. Example being if I have a health variable on one script can I access onto another and use it on another? Please HELP ME and Thank You for your time!

What you are trying to do is called referencing. You need a gameobject that acts as the GameManger. The game manager needs a reference to the class that contains the variable. Here is a link to help: Referencing non static variables from another script? C# - Unity Answers


In the gamemanager, reference the class, make an if statement that checks if the health is below a certain threshold and go from there (enabling the canvas with UI for the end screen, reloading the level, etc). To display the player’s name, you need to have the UnityEngine.UI namspace, a text element, and two separate strings with each players name. Once the if condition is met, update the text element with the string that contains the winner’s name.

@devondyer Thank You for your help I have now gotten it to work!!!