[Unity] Time.time 时间

查看:663 |回复:3 | 2015-4-6 11:20:30

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 大西几 于 2021-2-24 16:19 编辑

Time.time 时间
static var time : float

Description描述

The time this frame has started (Read Only). This is the time in seconds since the start of the game.

此帧开始的时间(只读)。这是以秒计算到游戏开始的时间。也就是说,从游戏开始到到现在所用的时间。

When called from inside MonoBehaviour's FixedUpdate, returns fixedTime property.

当在MonoBehaviour的FixedUpdate里调用的时候,返回的是fixedTime属性。

C#JavaScript
// Instantiates a projectile off every 0.5 seconds,
// if the Fire1 button (default is ctrl) is pressed.
//如果Fire1按钮被按下(默认为ctrl),每0.5秒实例化一发子弹
var projectile : GameObject;
var fireRate = 0.5;
private var nextFire = 0.0;

function Update () {
        if (Input.GetButton ("Fire1") && Time.time > nextFire) {
                nextFire = Time.time + fireRate;
                var clone = Instantiate (projectile, transform.position, transform.rotation);
        }
}
image.png
2015-4-6 11:20:30  
 赞 赞 1

使用道具 登录

3个回答,把该问题分享到群,邀请大神一起回答。
2#
谢谢分享
回复 收起回复
2018-10-20 20:50:12   回复
 赞 赞 1

使用道具 登录

3#
资源哪里好,肯定元素找!
回复 收起回复
2018-10-20 21:12:12   回复
 赞 赞 1

使用道具 登录

4#
66666666666
回复 收起回复
2018-10-20 21:41:56   回复
 赞 赞 1

使用道具 登录

CG 游戏行业专业问题

Unity3D技术手机游戏引擎手游引擎
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表