Dive deeper into creating advanced end screens for your games 👉 Check out my newest course, Master Unity UI ➡ bit.ly/cc-unity-ui-19 It’s packed with everything you need to create awesome UI ✨🎨
Thanks for the tutorial. Also, today I learned that you can call a method on a disabled GameObject whose script has SetActive in it and it'll activate the same object! Thank you for that too!
the first code using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class restartgame : MonoBehaviour { variables public gameoverscreen Gameoverscreen; int maxplatform = 0; public void gameover(){ Gameoverscreen.setup(maxplatform); } private void Awake() void start() void spawnplatforms() void spawn10more() public void touchedplatform(string name) } secund code using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class restartgame : MonoBehaviour { public void restartbutton(){ SceneManager.LoadScene("game"); } public void exitbutton(){ SceneManager.LoadScene("mainmenu"); } }
everything works correctly except the buttons don't work whatsoever... i have the same methods and attached them to the buttons but i am still able to see the character move after they die, so is there something i am missing with pausing the game or something?
great tutorial! how would you make the game over screen 'fade in' after the player loses? i'm trying to change the alpha of the background in my script in an IEnumerator but having trouble, any tips?
Good tutorial. only thing is i found a "glitch" where when i press the button to load the scene, everything appears but the game freezes and i can't do anything. does anyone have a fix for this??
4 months later, you probably set the time.deltatime to 0 upon death, try setting to 1 in the start method so that everytime the scene reloads the speed will be normal and wont freeze
what is game over screen supposed to be? im getting an error: error CS0246: The type or namespace name 'GameOverScreen' could not be found (are you missing a using directive or an assembly reference?)
I really liked this tutorial the only problem is I can't figure out how to get the game over screen to trigger. like in your game, its when your little guy hits the bottom of the screen. what does that code look like?
Exactly, it's a really good tutorial but there is no trigger in this one that I can see. I am assuming that he has some logic somewhere that calls this GameOver() method.
Hey the way I did it was by using onCollisionEnter2D instead of is trigger then I used a co Routine to handle the dying animations and game over menu. Maybe try not using trigger?
Its going to depend on how you do it, if you are making a different style game, then your trigger will be different. If you are trying to copy his game then you could probably use a collider on a 2d object and when the player hits that collider, it triggers the end.
after following your tutorial i keep getting error about "Text" not being found. why is that? This code in the GameOverScreen script public Text pointsText; public void Setup(int score) { gameObject.SetActive(true); pointsText.text = score.ToString() + "POINTS"; }
i stopped game with time.timescale=0; but i cant work this code "Button.interactable=true;" i searched and i probably i need to solve this with time.unscaledTime but how can i do it? help me plz
hello, i am a beginner and i followed brackeys tutorial to create my first game. How can i add this game over game to my project? it is different from your
neither exit nor restart appear as options in 5:40, no idea why honestly im this close to giving up just because of the sheer amount of problems that Im having that defy logic itself
can someone tell me what is the maxPlatform for? bcuz when my player dead, the game over menu not show up, and idk how to call the game over menu (sorry for my english)
You can create a variable like "bool isGameOver = false" which turns to 'true' when GameOver is visible. Based on that, you can check with each input if this variable is set to false.
Hi Im having Trouble I keep getting the Error GameController.cs(10,5): error CS1585: Member modifier 'public' must precede the member type and name This is the Code Can You Help ??? using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameController : MonoBehaviour { variables public GameOverScreen GameOverScreen; int maxPlatform = 0; public void GameOver() { GameOverScreen.Setup(maxPlatform); } private void Awake(); void Start(); void SpawnPlatforms() ; void Spawn10More() ; public Void TouchedPlatform(string name) ; }
year later, maybe you didn't closed the brackets? public class GameController : MonoBehaviour { variables public GameOverScreen GameOverScreen; int maxPlatform = 0; // like here must be brackets or idk bc at the next line bracket is opening so public void GameOver() {
1) At the beginning of our script, we need to say that we want to use the TextMesh Pro codeset. This can be done as follows: using TMPro; 2) Also, the variable's type will no longer be "Text". Instead of "Text" we will use the type "TextMeshProUGUI". hope it helped :p
just basically put your score in the void Start() function and set it there to be zero, so that every time the script run/ the game reloads it reads the script and will see that the points will be set again to 0
Dive deeper into creating advanced end screens for your games
👉 Check out my newest course, Master Unity UI ➡ bit.ly/cc-unity-ui-19
It’s packed with everything you need to create awesome UI ✨🎨
all fun and games till he shows the game controller
I would like to say thank you for your focus on the UI aspect of Unity, you're a reference for me in the matter. Keep up your work !!
💜 Would love to see your Game over screens on 🥥COCO CODE Discord: discord.gg/hNnZRnqf4s
Thanks for the tutorial. Also, today I learned that you can call a method on a disabled GameObject whose script has SetActive in it and it'll activate the same object! Thank you for that too!
the first code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class restartgame : MonoBehaviour
{
variables
public gameoverscreen Gameoverscreen;
int maxplatform = 0;
public void gameover(){
Gameoverscreen.setup(maxplatform);
}
private void Awake()
void start()
void spawnplatforms()
void spawn10more()
public void touchedplatform(string name)
}
secund code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class restartgame : MonoBehaviour
{
public void restartbutton(){
SceneManager.LoadScene("game");
}
public void exitbutton(){
SceneManager.LoadScene("mainmenu");
}
}
You are humanity's last hope Dear worldtrending24.76
for those whose background doesn't appear, don't forget to put the game over script into the player trigger script, then call GameOver();
god damn thank you for that tutorial, I spent a lot of time trying to find a decent one
I NEARLY FELL INTO MY OWN MEAT GRINDER WHILE WATCHING THIS TUTORIAL.
Are you insane?
no just obese
everything works correctly except the buttons don't work whatsoever... i have the same methods and attached them to the buttons but i am still able to see the character move after they die, so is there something i am missing with pausing the game or something?
Nice tutorial this definatly helped me
How and where do you call the GameOver method?
How would you handle a score that is in game before the game over screen?
Thank you.
get the scor var and put that into the gameoverscreen script so you can display that text
great tutorial! how would you make the game over screen 'fade in' after the player loses? i'm trying to change the alpha of the background in my script in an IEnumerator but having trouble, any tips?
Okay but what's the code for the death? when he falls he collides with a box collider? why did u skip that part, I'm a begginer :c
Thanks man, great video, worked like a charm.
Good tutorial. only thing is i found a "glitch" where when i press the button to load the scene, everything appears but the game freezes and i can't do anything. does anyone have a fix for this??
4 months later, you probably set the time.deltatime to 0 upon death, try setting to 1 in the start method so that everytime the scene reloads the speed will be normal and wont freeze
@@PoddyBrawlstars Same problem, and ur solution helped me. Thank You soooo much!
thanks made it work even with my way
what is game over screen supposed to be? im getting an error: error CS0246: The type or namespace name 'GameOverScreen' could not be found (are you missing a using directive or an assembly reference?)
I really liked this tutorial the only problem is I can't figure out how to get the game over screen to trigger. like in your game, its when your little guy hits the bottom of the screen. what does that code look like?
Exactly, it's a really good tutorial but there is no trigger in this one that I can see. I am assuming that he has some logic somewhere that calls this GameOver() method.
Hey the way I did it was by using onCollisionEnter2D instead of is trigger then I used a co Routine to handle the dying animations and game over menu. Maybe try not using trigger?
Any workaround on this after a year?
Its going to depend on how you do it, if you are making a different style game, then your trigger will be different. If you are trying to copy his game then you could probably use a collider on a 2d object and when the player hits that collider, it triggers the end.
I have a question: why is the resolution of my button veeery low, I even see the pixels. Help pls
after following your tutorial i keep getting error about "Text" not being found. why is that?
This code in the GameOverScreen script
public Text pointsText;
public void Setup(int score)
{
gameObject.SetActive(true);
pointsText.text = score.ToString() + "POINTS";
}
Are you sure you've typed "using UnityEngine.UI" at the very top of the script?
what do i have to write in the brackets after "GameOverScreen.Setup()" cuz i dont know what he means with "Pass in points"
Whatever you are calling your score counter in your script. So it may be score, points, etc.
I love your tutorials
How and Where is GameOver method called?
thank you so much for this great vid it really helped me
Thank you so much!
Nice tutorial! keep up bro
Thanks!
GOOD video bro, thank you.
This is a great tutorial and i need help with the game controller script
You didn't explain you have to put in the Event System for buttons to work. Spent half an hour to figure that out.
i stopped game with time.timescale=0; but i cant work this code "Button.interactable=true;" i searched and i probably i need to solve this with time.unscaledTime but how can i do it? help me plz
What I have to do if after "try again" cubes change colors to darker one??
Say please.
How do I add the game controller? I'm still new to this, and I'm trying to adjust my own project. It's not working because certain parts aren't called
Same
Same problem i faced
Still i can't fix the errors
@@sairampidugu6161 which part isn't working? If you don't have any compiler errors, you should just be able to drag and drop on top your objects??
thank you thank you thank youuuuu thaaaaaanks omg
hello, i am a beginner and i followed brackeys tutorial to create my first game. How can i add this game over game to my project? it is different from your
What If I have multiple levels then what should I enter in the public void RestartButton() {SceneManagaer.LoadScene(" "); ?
Great tutorial. Thank you :)
neither exit nor restart appear as options in 5:40, no idea why
honestly im this close to giving up just because of the sheer amount of problems that Im having that defy logic itself
Everything works except for the buttons. When i click them nothing happens
same here
The problem with me that game over UI is showing while playing I don't know the reason.
Why i have error namespace name 'GameOverScreen' could not be found
thanks 😊
can someone tell me what is the maxPlatform for? bcuz when my player dead, the game over menu not show up, and idk how to call the game over menu (sorry for my english)
I have no idea. I'm not able to move ahead because I don't know what his "maxPlatform" is.
good video, thank you!
Glad you liked it!
@@CocoCode how to get the code for when your user drop to the bottom and die?
in my game before this tutorial after death it just freezes xD and one question how can i blend out an other canvas with score usw? edit: fixed it
pro tip: you can watch movies at Flixzone. I've been using it for watching loads of movies lately.
@Hassan Ruben Yea, I've been watching on flixzone for years myself :)
I wish you would show how to make it appear when you loose....
what if i make the game over UI in another scene instead and move to that scene when the game is lost?
this method doesnt work with prefabs. when you try to load the object it disappears
Good job
why is it after I press the button It works how it should be but suddenly freezes the game?
How do you stop the game from being played in the background? The screen pops up but the game can still be played?
The easiest way would be to type Time.timeScale = 0;
You can read more about it here:
docs.unity3d.com/ScriptReference/Time-timeScale.html
What should I put instead of maxPlatform?
It depends on your game! It can be time value, reached level and more 🕺
Nice tutorial, but when I do the Alt + click for the size it just get really big and in a weird position.
what's considered the game controller by the way? I'm getting errors from it and i dunno what it is. (I'm new to coding)
Maybe a Script you have?
I'm not following the tutorial, but I assume it since its what he used it in the video.
i have a problem the load scene does not want to load.
damn ! even in 4k 😆
Doing my best to keep the best quality - sometimes small Unity elements may be difficult to read
could i also use that for topdown games as well? the only problem is that i dont have gravity effects, any tips?
Just know when the players HP is = 0, and then call the GameOver() function :D
How do I get a spectrum and c64 loading type screen on unity?
thanks
Hey! How can I do that if the Game over screen appears, buttons to move my character will not work or sounds stop?
You can create a variable like "bool isGameOver = false" which turns to 'true' when GameOver is visible. Based on that, you can check with each input if this variable is set to false.
this doesn't even kind of work for what I'm doing!
Can you give me the video for making the Game Controller script pls. Pls, pretty pls.
I mean the link.
restart button not working?
how do i make that to resume from current level?
Can anyone please help me on this error --> Member modifier 'public' must precede the member type and name
its from the public GameOverScreen GameOverScreen; line
if i fail my coins do not restart
they just continue
Why doesn't my screen appear??
but i dont have a game controller script
I don't know how to fix it.
What does ... mean in the scripts?
Hi Im having Trouble I keep getting the
Error
GameController.cs(10,5): error CS1585: Member modifier
'public' must precede the member type and name
This is the Code Can You Help ???
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameController : MonoBehaviour
{
variables
public GameOverScreen GameOverScreen;
int maxPlatform = 0;
public void GameOver() {
GameOverScreen.Setup(maxPlatform);
}
private void Awake();
void Start();
void SpawnPlatforms() ;
void Spawn10More() ;
public Void TouchedPlatform(string name) ;
}
Uh buddy, where to start!?
Have you fixed it? can you please tell me what did you do?
i have the same problem plz tell me how if u fixed it plz
year later, maybe you didn't closed the brackets?
public class GameController : MonoBehaviour
{
variables
public GameOverScreen GameOverScreen;
int maxPlatform = 0;
// like here must be brackets or idk bc at the next line bracket is opening so
public void GameOver() {
what can i change max platform too??
3:50
Have the same problem idk
I cant't do this because I can only use TextMeshPro
1) At the beginning of our script, we need to say that we want to use the TextMesh Pro codeset. This can be done as follows:
using TMPro;
2) Also, the variable's type will no longer be "Text". Instead of "Text" we will use the type "TextMeshProUGUI".
hope it helped :p
But how to add game over sound
i hate life... i just wanted a way to connect my health code to a game over screen.
HOW I KNOW WHAT IS MY SETUP3:57
i dont have regular text just have textMeshPro i dont have any font
Go to UI, hover over the option Legacy, and you'll see Text
how did you make the corners soft
Check out this video!
Master your Unity UI Buttons! - Unity UI tutorial th-cam.com/video/cW-E4WEogzE/w-d-xo.html
@@CocoCode Thanks sir
is there a line of code that can make my score go back to zero after restarting the game. My game starts with the same score as when i died plsss help
just basically put your score in the void Start() function and set it there to be zero, so that every time the script run/ the game reloads it reads the script and will see that the points will be set again to 0
My borthday was today ;-;
For me it says that ; is not expected.
You forgot to write ; after some line of code
Learn to read your errors, everything is easy to understand from them
public gameoverscreen gameoverscreen? wtf
How to do it without player
Could you please specify?
Like if you have game without player like some more items for player how to do score on the geover screen
its dosnt work thanks
Hi i need unity pro for free
it didn't work :(
I invite you to coco code Discord, hope I'll be able to resolve your issue there!
discord.gg/hNnZRnqf4s
This is a really good tutorial, thanks!