Time.timeScale 时间缩放

static var timeScale : float

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.

当timeScale传递时间1.0时和实时时间一样快。当timeScale传递时间0.5时比实时时间慢一半。

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

当timeScale传递时间为0时游戏基本上暂停了,如果你的所有函数是和帧速率无关的。

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

除了realtimeSinceStartup,timeScale影响所有时间和增量时间基于Time类的变量。

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

如果降低timeScale,建议也降低Time.fixedDeltaTime同样的数值。

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

当timescale设置为0时,FixedUpdate函数将不会被调用。

// Toggles the time scale between 1 and 0.7
// whenever the user hits the Fire1 button.
//切换时间缩放在1-0.7之间,每当用户点击Fire1按钮。
function Update () {
if (Input.GetButtonDown ("Fire1")) {
    if (Time.timeScale == 1.0)
        Time.timeScale = 0.7;
    else
        Time.timeScale = 1.0;
    // Adjust fixed delta time according to timescale    
    // The fixed delta time will now be 0.02 frames per real-time second
    //根据timescale调整固定增量时间。
    Time.fixedDeltaTime = 0.02 * Time.timeScale;
    }
}

 

转载于:https://www.cnblogs.com/vincentDr/p/3681067.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值