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"); } }
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!
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?
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
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)
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
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.
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
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() {
all fun and games till he shows the game controller
💜 Would love to see your Game over screens on 🥥COCO CODE Discord: discord.gg/hNnZRnqf4s
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
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 !!
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!
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
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?
I NEARLY FELL INTO MY OWN MEAT GRINDER WHILE WATCHING THIS TUTORIAL.
Are you insane?
no just obese
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
Nice tutorial this definatly helped me
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!
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.
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.
This is a great tutorial and i need help with the game controller script
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
How and Where is GameOver method called?
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?
Thanks man, great video, worked like a charm.
thank you so much for this great vid it really helped me
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
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 wish you would show how to make it appear when you loose....
Why i have error namespace name 'GameOverScreen' could not be found
What I have to do if after "try again" cubes change colors to darker one??
Say please.
Nice tutorial! keep up bro
Thanks!
thanks made it work even with my way
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??
The problem with me that game over UI is showing while playing I don't know the reason.
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
what if i make the game over UI in another scene instead and move to that scene when the game is lost?
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.
i have a problem the load scene does not want to load.
this method doesnt work with prefabs. when you try to load the object it disappears
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 :)
What If I have multiple levels then what should I enter in the public void RestartButton() {SceneManagaer.LoadScene(" "); ?
why is it after I press the button It works how it should be but suddenly freezes the game?
I love your tutorials
GOOD video bro, thank you.
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
restart button not working?
Thank you so much!
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
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
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.
damn ! even in 4k 😆
Doing my best to keep the best quality - sometimes small Unity elements may be difficult to read
Everything works except for the buttons. When i click them nothing happens
same here
I don't know how to fix it.
how do i make that to resume from current level?
thank you thank you thank youuuuu thaaaaaanks omg
Great tutorial. Thank you :)
but i dont have a game controller script
Can you give me the video for making the Game Controller script pls. Pls, pretty pls.
I mean the link.
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
How do I get a spectrum and c64 loading type screen on unity?
Good job
this doesn't even kind of work for what I'm doing!
But how to add game over sound
Why doesn't my screen appear??
good video, thank you!
Glad you liked it!
@@CocoCode how to get the code for when your user drop to the bottom and die?
thank you
What does ... mean in the scripts?
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.
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.
if i fail my coins do not restart
they just continue
what can i change max platform too??
3:50
Have the same problem idk
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
thanks
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
i hate life... i just wanted a way to connect my health code to a game over screen.
how did you make the corners soft
Check out this video!
Master your Unity UI Buttons! - Unity UI tutorial ruclips.net/video/cW-E4WEogzE/видео.html
@@CocoCode Thanks sir
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
My borthday was today ;-;
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
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
its dosnt work thanks
Hi i need unity pro for free
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() {
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!