How to pause the game in Uniy3D

How to pause the game in Uniy3D

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

static float
timeScale;

Description

The scale at which the time is passing. This can be used for slow motion effects.

When timeScale is 1.0 the time is passing as fast as realtime.When timeScale is 0.5 the time is passing 2x slower than realtime.

When timeScale is set to zero the game is basically paused if all your functions areframe rate independent.

Except for realtimeSinceStartup, timeScale affects all the time and delta time measuring variables of the Time class.

If you lower timeScale it is recommended to also lower Time.fixedDeltaTime by the same amount.

FixedUpdate functions will not be called when timeScale is set to zero.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Update() {
        if (Input.GetButtonDown("Fire1")) {
            if (Time.timeScale == 1.0F)
                Time.timeScale = 0.7F;
            else
                Time.timeScale = 1.0F;
            Time.fixedDeltaTime = 0.02F * Time.timeScale;
        }
    }
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117409.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • list对象转map[通俗易懂]

    list对象转map[通俗易懂]根据list对象中的某个属性转换成map/***将对象中的某个属性作为map的key将对象本身作为map的value构成成一个map**@paramfieldToKey必须是obj的field我们把field的getValue作为map的key*@authormountain2019-01-0717:21*/publicstatic<T,E>Map<T,E>listToM

    2022年5月13日
    73
  • Pytorch-DataLoader的使用

    Pytorch-DataLoader的使用原文连接:http://chenhao.space/post/d313d236.htmlpytorch-DataLoader的使用importtorchimporttorch.utils.dataasData#[1,1,1]相当于一句话的wordembedding,这个tensor中含有三句话x=torch.tensor([[1,1,1],[2,2,2…

    2022年5月14日
    34
  • (Python学习4)List对象

    1、PyListObject对象PyObject_VAR_HEAD中的obsize表示该list对象含有的元素个数,而allocated表示该list对象占用的内存空间。ob_item实际指向一个指

    2021年12月23日
    150
  • visual studio运行程序的快捷键_visual studio快捷方式在哪

    visual studio运行程序的快捷键_visual studio快捷方式在哪目录一、系统快捷键二、常用系统命令三、QQ快捷键四、IE浏览器快捷键使用大全五、Word 中的快捷键六、Excel 中的快捷键七、PowerPoint 中的快捷键八、Visual Studio九、Eclipse十、Photoshop十一、批处理指令十二、安装操作系统(此快捷操作对我们程序员十分重要,所以放在前面)八、Visual Studio8.1、项目相关的快捷键…

    2022年8月18日
    3
  • nginx自动重启脚本_nginx进程数和连接数

    nginx自动重启脚本_nginx进程数和连接数工作中经常要杀掉nginx对应的进程,然后手动命令重启和删除nginx日志,每次都要输入3个或3个以上的命令,效率低。写个脚本万事大吉。#!/bin/shNAME=”nginx-p/home/proj/gamebin/-cconf/depnginx.conf”ID=`ps-ef|grep”$NAME”|grep-v”$0″|grep-v”…

    2022年8月13日
    2
  • MAC电脑 系统 恢复出厂设置

    MAC电脑 系统 恢复出厂设置具体步骤:1首先开启Mac的电源开关,同时按住command+R键进入恢复模式,我们就能看MacOSX实用工具。2选择磁盘工具–然后选择上面一般是MacintoshHD这个选项,右侧选择抹掉。意思就是删除所有内容重新安装新的系统。3重新启动Mac,这时出现地球标志,等待更新完成。这里PC6小编要提醒各位进行这项操作的Mac用户,由于在线恢复需要从苹果服务器下载完整的OS

    2022年6月21日
    31

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号