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