How to pause Unity game | Simple Unity 2D tutorial

22
1



#UnityTutorial #SimpleUnityGame #unitypausegame #unitypause
In this video I will show how you can add a pause function to your Unity game. We create a UI button and make a script which will be attached to this button. When you click or push this button your game stops until you push pause button again. Very simple solution. We use Time.timeScale=0 to stop game running and Time.timeScale=1 to run a game.

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

www.vecteezy.com – best free vector graphics library ever!

What this video is about and what it can be used for also: unity 2d tutorial,
How to pause Unity game, how to pause, how to pause unity, pause game unity, pause button unity, stop game unity, how to stop game running unity, pause function unity, game paused unity, how can I pause unity game, unity pause, unity pause game, pause, Time.timeScale=0, Time.timeScale=1, pause UI button unity, pause button unity, pause 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://khosimphongthuy.net/

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

22 COMMENTS

  1. Script

    using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;

    public class PauseScript : MonoBehaviour {

    bool isPaused = false;

    public void pauseGame()

    {

    if (isPaused) {

    Time.timeScale = 1;

    isPaused = false;

    } else {

    Time.timeScale = 0;

    isPaused = true;

    }

    }

    }

  2. What does time.timescale=0 actually affect? Is it literally everything in the game stops mid-move? Rigidbodies, UI elements, animation, etc?

  3. This doesn't really work as I thought: My enemy characters stop moving and their animations are paused but I can still hear the sounds of them firing every now and then; my gun still fires and the bullet shells eject (which I actually still want to happen when the game is paused) but the shells are instantly just floating still in midair; if I shoot at enemies they still play their impact animations even though the game is paused; etc. The game basically isn't really paused much at all it seems to me.
    Also what about stuff I don't want to pause that might automatically be paused using this method: How do I stop that stuff pausing automatically here?

  4. I'm making a Kinect game using Unity.
    I created a pause function while playing the game and stopped using Time.timeScale = 0 when the menu Canvas was opened using the button UI.
    However, after connecting the Kinect menu Canvas is up, but Time.timeScale = 0 function is gone.
    Why? Are timescale ignored while connecting? There is no way ???

LEAVE A REPLY

Please enter your comment!
Please enter your name here