Time.deltaTime //逐帧
transform.Translate(Vector3.forward * Time.deltaTime);//朝着一个方向前进
游戏的暂停开始
Time.timeScale = 0;//游戏暂停
//游戏暂停之后就停止了
Time.timeScale = 1;//游戏暂停
克隆
public GameObject qiu;
GameObject q1, q2;
float timer = 3f;
void Start () {
q1=Instantiate(qiu);//在预设体的位置克隆一个球
//在(1,1,1)的位置克隆一个球
q2=Instantiate(qiu, Vector3.one, Quaternion.identity);
//(要克隆的物体,克隆后物体的坐标,是否旋转)Quaternion.identity:不旋转
}
删除物体
void Update () {
timer -= Time.deltaTime;
if (timer<=0)
{
Destroy(q1);//直接删除物体
}
Destroy(q2, 5);//5秒后删除物体
}
}
随机数
float a = Random.v