Create great GAME OVER screen in Unity UI - Unity tutorial

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024

Комментарии • 133

  • @UnravelCuriosities
    @UnravelCuriosities 3 года назад +57

    all fun and games till he shows the game controller

  • @CocoCode
    @CocoCode  3 года назад +7

    💜 Would love to see your Game over screens on 🥥COCO CODE Discord: discord.gg/hNnZRnqf4s

  • @worldtrending24.76
    @worldtrending24.76 Год назад +10

    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");
    }
    }

    • @mentalabuser6559
      @mentalabuser6559 8 месяцев назад

      You are humanity's last hope Dear worldtrending24.76

  • @princetruth28
    @princetruth28 2 года назад +15

    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 !!

  • @CassiusJohnAdams
    @CassiusJohnAdams 3 года назад +17

    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!

  • @556mm4
    @556mm4 2 года назад +9

    for those whose background doesn't appear, don't forget to put the game over script into the player trigger script, then call GameOver();

  • @cognosce6193
    @cognosce6193 3 года назад +4

    god damn thank you for that tutorial, I spent a lot of time trying to find a decent one

  • @basicallybruh9769
    @basicallybruh9769 3 года назад +5

    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?

  • @slingerbuikers
    @slingerbuikers Год назад +2

    I NEARLY FELL INTO MY OWN MEAT GRINDER WHILE WATCHING THIS TUTORIAL.

  • @mina7572
    @mina7572 2 года назад +8

    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.

    • @shxrdz9628
      @shxrdz9628 Год назад

      get the scor var and put that into the gameoverscreen script so you can display that text

  • @gealastefan813
    @gealastefan813 3 года назад +5

    Nice tutorial this definatly helped me

  • @unamusedrowlett6303
    @unamusedrowlett6303 3 года назад +6

    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??

    • @PoddyBrawlstars
      @PoddyBrawlstars 2 года назад

      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

    • @NigeryjskaDysplazja
      @NigeryjskaDysplazja 2 года назад +1

      @@PoddyBrawlstars Same problem, and ur solution helped me. Thank You soooo much!

  • @aikiadu7995
    @aikiadu7995 3 года назад +4

    what do i have to write in the brackets after "GameOverScreen.Setup()" cuz i dont know what he means with "Pass in points"

    • @scree06
      @scree06 3 года назад

      Whatever you are calling your score counter in your script. So it may be score, points, etc.

  • @thejahoobasdeveloper
    @thejahoobasdeveloper 2 года назад +1

    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?)

  • @Phantaric
    @Phantaric 2 года назад +14

    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?

    • @ruinamuckyfuddle
      @ruinamuckyfuddle 2 года назад +3

      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.

    • @bobbville
      @bobbville 2 года назад

      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?

    • @finalproject8821
      @finalproject8821 Год назад

      Any workaround on this after a year?

    • @JasperFunk
      @JasperFunk Год назад +3

      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.

  • @vilanstrikegaming5114
    @vilanstrikegaming5114 2 года назад +3

    This is a great tutorial and i need help with the game controller script

  • @danielnunoavina
    @danielnunoavina Год назад +4

    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

  • @ulasonen9071
    @ulasonen9071 3 года назад +3

    How and Where is GameOver method called?

  • @xDTHECHEMISTx
    @xDTHECHEMISTx 2 года назад +1

    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";
    }

    • @CocoCode
      @CocoCode  2 года назад

      Are you sure you've typed "using UnityEngine.UI" at the very top of the script?

  • @agonzio2107
    @agonzio2107 2 года назад +1

    Thanks man, great video, worked like a charm.

  • @sebastianjones3815
    @sebastianjones3815 3 года назад +1

    thank you so much for this great vid it really helped me

  • @byram_brt
    @byram_brt 10 месяцев назад

    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

  • @alexbratov3095
    @alexbratov3095 6 месяцев назад

    You didn't explain you have to put in the Event System for buttons to work. Spent half an hour to figure that out.

  • @stopingscammers9720
    @stopingscammers9720 2 года назад +1

    I wish you would show how to make it appear when you loose....

  • @baoaichauvo4893
    @baoaichauvo4893 Год назад

    Why i have error namespace name 'GameOverScreen' could not be found

  • @yuki_mosu
    @yuki_mosu 3 года назад +1

    What I have to do if after "try again" cubes change colors to darker one??
    Say please.

  • @8DSONGENG
    @8DSONGENG 3 года назад +2

    Nice tutorial! keep up bro

  • @tharabhaijoinderek3395
    @tharabhaijoinderek3395 2 года назад

    thanks made it work even with my way

  • @scree06
    @scree06 3 года назад +2

    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

    • @mei4195
      @mei4195 3 года назад

      Same

    • @sairampidugu6161
      @sairampidugu6161 2 года назад +1

      Same problem i faced
      Still i can't fix the errors

    • @bobbville
      @bobbville 2 года назад

      @@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??

  • @HUSS_BOSS
    @HUSS_BOSS 2 года назад

    The problem with me that game over UI is showing while playing I don't know the reason.

  • @Lost_S
    @Lost_S Год назад

    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

  • @Umrjak
    @Umrjak Год назад

    what if i make the game over UI in another scene instead and move to that scene when the game is lost?

  • @who8554
    @who8554 2 года назад +1

    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)

    • @ryanem969
      @ryanem969 Год назад

      I have no idea. I'm not able to move ahead because I don't know what his "maxPlatform" is.

  • @WarTutel
    @WarTutel Год назад

    i have a problem the load scene does not want to load.

  • @mandyronald8187
    @mandyronald8187 3 года назад

    this method doesnt work with prefabs. when you try to load the object it disappears

  • @Hund335
    @Hund335 3 года назад +3

    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

    • @hassanruben1019
      @hassanruben1019 3 года назад

      pro tip: you can watch movies at Flixzone. I've been using it for watching loads of movies lately.

    • @gaellucas8705
      @gaellucas8705 3 года назад

      @Hassan Ruben Yea, I've been watching on flixzone for years myself :)

  • @shailnakum9601
    @shailnakum9601 3 года назад

    What If I have multiple levels then what should I enter in the public void RestartButton() {SceneManagaer.LoadScene(" "); ?

  • @aljonmariano8447
    @aljonmariano8447 3 года назад

    why is it after I press the button It works how it should be but suddenly freezes the game?

  • @LixTheYT
    @LixTheYT 2 года назад

    I love your tutorials

  • @leonardobrandalise8824
    @leonardobrandalise8824 3 года назад

    GOOD video bro, thank you.

  • @redeiking5289
    @redeiking5289 3 года назад

    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

  • @maxisneis6791
    @maxisneis6791 3 года назад +1

    restart button not working?

  • @ozgurozanozbay2346
    @ozgurozanozbay2346 Год назад

    Thank you so much!

  • @704tuti
    @704tuti Год назад

    How do you stop the game from being played in the background? The screen pops up but the game can still be played?

    • @CocoCode
      @CocoCode  Год назад

      The easiest way would be to type Time.timeScale = 0;
      You can read more about it here:
      docs.unity3d.com/ScriptReference/Time-timeScale.html

  • @isimsizanimator1291
    @isimsizanimator1291 Год назад

    i dont have regular text just have textMeshPro i dont have any font

    • @sophiashanthan8101
      @sophiashanthan8101 Год назад

      Go to UI, hover over the option Legacy, and you'll see Text

  • @ethanb8361
    @ethanb8361 3 года назад +1

    What should I put instead of maxPlatform?

    • @CocoCode
      @CocoCode  3 года назад +1

      It depends on your game! It can be time value, reached level and more 🕺

  • @bonkthesystem
    @bonkthesystem 2 года назад

    Nice tutorial, but when I do the Alt + click for the size it just get really big and in a weird position.

  • @uchihai_a_h4871
    @uchihai_a_h4871 3 года назад +2

    damn ! even in 4k 😆

    • @CocoCode
      @CocoCode  3 года назад +1

      Doing my best to keep the best quality - sometimes small Unity elements may be difficult to read

  • @AKumar1992
    @AKumar1992 3 года назад +1

    Everything works except for the buttons. When i click them nothing happens

  • @samorian7397
    @samorian7397 3 года назад +1

    I don't know how to fix it.

  • @psadicodes
    @psadicodes 2 года назад

    how do i make that to resume from current level?

  • @Kackenswert
    @Kackenswert 3 года назад

    thank you thank you thank youuuuu thaaaaaanks omg

  • @MrDelord39
    @MrDelord39 3 года назад +2

    Great tutorial. Thank you :)

  • @rasmus5990
    @rasmus5990 Год назад

    but i dont have a game controller script

  • @fabianlo234
    @fabianlo234 9 месяцев назад

    Can you give me the video for making the Game Controller script pls. Pls, pretty pls.

  • @UnravelCuriosities
    @UnravelCuriosities 3 года назад

    Can anyone please help me on this error --> Member modifier 'public' must precede the member type and name

    • @UnravelCuriosities
      @UnravelCuriosities 3 года назад

      its from the public GameOverScreen GameOverScreen; line

  • @random_precision_software
    @random_precision_software 3 года назад

    How do I get a spectrum and c64 loading type screen on unity?

  • @user-wd5qd2rh5d
    @user-wd5qd2rh5d 3 года назад +1

    Good job

  • @TheOnlyKaas
    @TheOnlyKaas 2 года назад +1

    this doesn't even kind of work for what I'm doing!

  • @rekhapandey3941
    @rekhapandey3941 Год назад

    But how to add game over sound

  • @adityadwi9077
    @adityadwi9077 8 месяцев назад

    Why doesn't my screen appear??

  • @rafaellauxen3577
    @rafaellauxen3577 3 года назад

    good video, thank you!

    • @CocoCode
      @CocoCode  3 года назад +1

      Glad you liked it!

    • @finalproject8821
      @finalproject8821 Год назад

      @@CocoCode how to get the code for when your user drop to the bottom and die?

  • @Junior.Store.Google.Play.
    @Junior.Store.Google.Play. Год назад

    thank you

  • @fabianlo234
    @fabianlo234 9 месяцев назад

    What does ... mean in the scripts?

  • @orhanorhan2442
    @orhanorhan2442 Год назад

    thanks 😊

  • @marixxyt
    @marixxyt 3 года назад +1

    Hey! How can I do that if the Game over screen appears, buttons to move my character will not work or sounds stop?

    • @CocoCode
      @CocoCode  3 года назад

      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.

  • @ToastMah
    @ToastMah 3 года назад

    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)

    • @kami1o427
      @kami1o427 2 года назад

      Maybe a Script you have?
      I'm not following the tutorial, but I assume it since its what he used it in the video.

  • @davidemmanuel7603
    @davidemmanuel7603 Год назад

    if i fail my coins do not restart
    they just continue

  • @Mzain.
    @Mzain. 3 года назад +2

    what can i change max platform too??
    3:50

  • @adamblanza6937
    @adamblanza6937 3 года назад

    could i also use that for topdown games as well? the only problem is that i dont have gravity effects, any tips?

    • @drewster237
      @drewster237 Год назад +1

      Just know when the players HP is = 0, and then call the GameOver() function :D

  • @josemartinfriasaguirre1591
    @josemartinfriasaguirre1591 2 года назад

    thanks

  • @Malthazar1
    @Malthazar1 Год назад

    I cant't do this because I can only use TextMeshPro

    • @axdi9189
      @axdi9189 Год назад

      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

  • @chickenwizardthethird9386
    @chickenwizardthethird9386 3 года назад +1

    i hate life... i just wanted a way to connect my health code to a game over screen.

  • @m.b.a5260
    @m.b.a5260 3 года назад

    how did you make the corners soft

    • @CocoCode
      @CocoCode  3 года назад +2

      Check out this video!
      Master your Unity UI Buttons! - Unity UI tutorial ruclips.net/video/cW-E4WEogzE/видео.html

    • @m.b.a5260
      @m.b.a5260 3 года назад

      @@CocoCode Thanks sir

  • @samorian7397
    @samorian7397 3 года назад

    For me it says that ; is not expected.

    • @andytheoriginalname5722
      @andytheoriginalname5722 3 года назад +1

      You forgot to write ; after some line of code

    • @flaviokonti5522
      @flaviokonti5522 3 года назад +2

      Learn to read your errors, everything is easy to understand from them

  • @g4m3z24
    @g4m3z24 Год назад

    My borthday was today ;-;

  • @ramelsteel3782
    @ramelsteel3782 2 года назад +1

    public gameoverscreen gameoverscreen? wtf

  • @fl3xxo492
    @fl3xxo492 3 года назад

    How to do it without player

    • @CocoCode
      @CocoCode  3 года назад

      Could you please specify?

    • @fl3xxo492
      @fl3xxo492 3 года назад

      Like if you have game without player like some more items for player how to do score on the geover screen

  • @jatishkathard4427
    @jatishkathard4427 3 года назад

    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

    • @siamazing0828
      @siamazing0828 3 года назад +2

      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

  • @csgog4ming48
    @csgog4ming48 3 года назад +1

    its dosnt work thanks

  • @anonymousk5899
    @anonymousk5899 Год назад

    Hi i need unity pro for free

  • @flgaming2165
    @flgaming2165 3 года назад +1

    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) ;
    }

    • @flaviokonti5522
      @flaviokonti5522 3 года назад

      Uh buddy, where to start!?

    • @UnravelCuriosities
      @UnravelCuriosities 3 года назад

      Have you fixed it? can you please tell me what did you do?

    • @basharblus
      @basharblus 3 года назад +1

      i have the same problem plz tell me how if u fixed it plz

    • @whoami.....
      @whoami..... 2 года назад +1

      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() {

  • @ChrizBob
    @ChrizBob 3 года назад

    it didn't work :(

    • @CocoCode
      @CocoCode  3 года назад +1

      I invite you to coco code Discord, hope I'll be able to resolve your issue there!
      discord.gg/hNnZRnqf4s

  • @Lucky-.-
    @Lucky-.- 2 года назад +1

    This is a really good tutorial, thanks!