Game

Unity Tutorial How To Make Restart Button To Reload The Scene In Jetpack Clone Android Game




#unitytutorial #unityandroidtutorial #unityreloadbutton
In the previous video ( we created a Jetpack game prototype with pick up fuel can feature. In this video tutorial, we will add a restart button to our game so we will be able to reload the scene when fuel is over and play again.

The BEST MECHANICAL KEYBOARD Metoo Zero for the price. I use it. And I must say that it’s perfect!

Consider purchasing my ULTIMATE UDEMY COURSE with great discount

If you like what I’m doing then you can support me through
www.patreon.com/alexanderzotov
or here

Thank you)

What this video is about and what it can be used for also: unity 2d tutorial,
Unity Tutorial How To Make Restart Button, Unity Tutorial How To Make Restart Button To Reload The Scene, unity restart button, unity restart game, unity restart scene, unity restart level, unity restart game button, unity restart scene button, unity restart scene script, unity restart level script, unity reload current scene, unity reload scene, unity reload level,unity reload script, unity reload scene button, learn unity fast, unity tutorial, how to make games with unity, unity how to make game, unity how to make 2d game, not as good as brackeys but good as well.

Nguồn: https://britishmusicguide.com/

Xem thêm bài viết khác: https://britishmusicguide.com/game/

Game
She's the Man (8/8) Movie CLIP – I'm Viola (2006) HD
Game
LEGO TSUNAMI DESTROYS LEGO CITY BRIDGE! – Brick Rigs Gameplay Challenge – Lego City Disaster
Game
The Cast of Elite Plays Never Have I Ever | Netflix
  • ALARM! ALARM! COROUTINE ISSUE DETECTED!
    If you press and hold your finger at the very beginning of the game, pass through the comets without touching them, pick up the fuel can and fly off the screen without releasing your finger then fuel counter will freeze at some value and will not go down until you release and put finger back on the screen. It happens because of the coroutine. When it starts it takes the current fuel amount value (let it be 50 for example). Coroutine stops with two conditions – if finger is released or if fuel amount inside this coroutine is equal to zero. So if you pick up fuel can while coroutine is running when fuel amount equals to 50 then overall fuel amount becomes 100 back again. But inside the coroutine, it still goes down from 50. When coroutine is over (loop comes to zero) then engine should stop but it doesn't happen because fuel amount is 50 now. And it will always be 50 until you release the finger and put it back on the screen to start new coroutine which will countdown from 50 to 0.
    So to fix this issue we should replace this line in BurnFuel coroutine
    for (int i = fuelAmount; i >= 1; i–)
    with this line
    while (fuelAmount > 0)
    and everything will work fine.
    So coroutine code will look like this

    private IEnumerator BurnFuel()
    {
    while (fuelAmount > 0)
    {
    fuelAmount -= 1;
    yield return new WaitForSeconds(0.01f);

    if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
    //if (Input.GetMouseButtonUp(0))
    break;
    }
    }

    But we should use WHILE loop inside any of the coroutine very very carefully because it can halt the running project easily.


  • Why does my scene freeze after restarting?

    Edit: nvm I forgot to put Time.timeScale = 1f;


  • Script

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class Restart : MonoBehaviour {
    public void RestartGame()
    {
    SceneManager.LoadScene ("Scene Name);
    }
    }


  • You can probably set the scene that you want to reload as
    SceneManager.LoadScene(SceneManager.GetActiveScene())


  • thank you needed this for my game


  • y is this not working for meeeeeeeee


  • Спасибо большое за видео! Вы мой спаситель, Александр)
    Подскажите, у Вас есть видео, в котором бы объяснялось, как научить эту кнопку появляться только после смерти гг?


  • I don't know why it doesn't grab the click or the touch of the reset button. I did everything that appeared in the procedure. I even checked that the scene was the same as the code. Help!


  • Perfect!! Fast and simple like every Unity tutorial should be.


  • DSlutDSlut

    Author Reply

    Thanks for the tutorial! @Alex, I've got a question. I added a restart button to my simple puzzle game with WinText (see your another guide), and it happens that WinText stays on a screen when I press restart button. How I can avoid it and make full restart?


  • You are man


  • pls restart code write


  • my scene freezes after pressing the restart button


  • Thanks)


  • thank u so much!


  • simple and very clear, thank you!


  • what is the canvas?


  • So I have BG music in my game and whenever I reset the game, the music stays but another one plays again. Can you please help?


  • thank you but the semplescene can not Load into my projects


  • Great job sir


  • Can't find my restart button sprite in the project folder what do I do?


  • Thank you so much dude!!!!


  • thx man for this video


  • I am a beginner and wanted to integrate a restart button in my game. Thanks for helping me out.


  • The update function does not work after reloading the scene.


  • Alexander is one of the most informative and easy going Unity tutors in Youtube. I just love the mood and the valuable things you teach us man, straight to the point as always. Thanks!


  • Plzzz help me! I have no funktions? What can i do?


  • Hey i got a question, how do you assign a key to press a button in Unity?


  • I've been looking for a tutorial like this for a while – it's perfect. I have followed it to the letter but it doesn't work 🙁

    Got any suggestions as to why?


  • Can someone help me, i followed the code but after i restarted my game it freezes completely. Can someone help me out? thanks and muchly appreciate it!


  • Thanks a lot for short and simple tutorial…


  • man can you please please please make a video, how to build game in unity like what sdk or what java to use and how to install them just please and thanks


  • Amazing,please keep it up uploading your awesome tutorials?