Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-3
Question by dsillman2000 · Feb 23, 2014 at 01:12 AM · textcentergame over

How to display a "Game Over" after death?

I would like to code my game so that when my player dies(or is set inactive), black text shows up in the middle of the screen displaying "Game Over!"

How is this possible?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiloblargh · Feb 23, 2014 at 08:07 AM 0
Share

I believe it's done with magnets.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by morgan23 · Feb 23, 2014 at 01:25 AM

you could do it in script just make a bool that checks when player is dead then display a GUI or a GUItext.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dsillman2000 · Feb 23, 2014 at 01:30 AM 0
Share

How would I display the text? That's my main issue.

avatar image
0

Answer by morgan23 · Feb 23, 2014 at 01:53 AM

I can give you an example script for one option I have no experience with the game object GUItext. Here is a script I made for respawning my player when he dies. I will put a comment for what part you might be interested in this should work for what you want and if some stuff needs explaining I can help. public class PlayerRespawn : MonoBehaviour { //Public Variables

 public float ReSpawnTime = 0f;
 
 private int RespawnIndex= 0;
 private Camera MainCamera;
 public Transform[]ReSpawnLocation = new Transform[4];//Array For All My Repsawn Locations
 private PlayerVitals Pv;
 private GameGUI Gg;
 private bool ShowRespawnButton = false;
 public GameObject Player;
 //public Vector3 CameraPos = new Vector3(0,0,0);
 void Awake()
 {
 MainCamera = Camera.main; // Grab a reference to the camera
 
 //MainCamera = GameObject.FindWithTag("MainCamera");
 Gg = MainCamera.GetComponent();
 
 //Pv = GetComponent();
 Pv = GameObject.Find("Player").GetComponent();
 //Pv = Player.GetComponent();
 }
     // Use this for initialization
 
 void Update()
 {
 if(Pv.Life <= 0)
 {
 Dead(IsDead:true);
 
 //Debug.Log (ReSpawnLocation[RespawnIndex].name);
 
 }
 }
 **void OnGUI()
 {
 if(ShowRespawnButton)//This would be what you want
 if(GUI.Button(new Rect(10,10,75,40),"Respawn"))
 {**
 
 StartCoroutine("Respawn");
 }
 }
 
     //Method That ReSpawns The Player
    IEnumerator Respawn() 
 {
 yield return new WaitForSeconds(ReSpawnTime);    
 RespawnIndex = Random.Range(0,ReSpawnLocation.Length);
 Player.transform.position = ReSpawnLocation[RespawnIndex].position;
 MainCamera.transform.position = Player.transform.position;
 MainCamera.transform.localPosition = new Vector3(0f,0f,-15f);
 
 Pv.Life = Pv.MaxLife;
 Dead (false);
 yield return 0;
 StopCoroutine("Respawn");
 //Debug.Log ("Respawned");
 
 
 }    
 
 private void Dead (bool IsDead) 
 {
 
 
 if(IsDead ==true)
 {
 ShowRespawnButton = true;
 Gg.ShowGui = false;
 Player.renderer.enabled = false;
         
 //Debug.Log("you died");
 
 
 
 
 
 
 }
 
     
 if(IsDead==false)
 {
 ShowRespawnButton = false;
 Player.renderer.enabled = true;
 //StartCoroutine("MoveToTarget");
 //Debug.Log(IsDead);
 
 }
     }
             
 
 
 }
 
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TackyGuy · Aug 18, 2017 at 09:47 PM 0
Share

Trying to use your script but its really old. I tried to play around it and fix some things but i am not really good at program$$anonymous$$g so it didn't succeed. Do you have a more updated version ? If yes can you share it with me ? I've searched for like a week to kill and respawn my player and show a game over screen. Even tutorials couldn't help me. I hope you will have time to help me.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do i centralize one string in any viewport size? 1 Answer

Make UI always center the panel 1 Answer

Adding vertices to TextMesh Pro 0 Answers

Click ui text to dissapear in 3D unity 2017 first person game script for ui multiple texts?,Clicking Text away in Unity 2017 3D first person game 0 Answers

How to align text? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges