- 最后登录
- 2017-5-15
- 注册时间
- 2012-3-1
- 阅读权限
- 90
- 积分
- 32973
  
- 纳金币
- 32806
- 精华
- 12
|
1.// Destroy the character when it's out of view. 当移动距离为20时销毁对象
if (Vector3.Distance(Vector3.zero,transform.position) > 20)
Destroy(gameObject);
2.
function Start()
{
// Rotate the character to a random direction. 刚运行脚本时 在y轴生成任意的方向
transform.Rotate(0, Random.Range(0, 360), 0);
}
3.yield new WaitForSeconds(3); 等待3秒
yield WaitForSeconds(3);
4.var prefab : GameObject;
// This script creates a character prefab every 3 seconds,
// and places it at a random position.
while(***e)
{
go = Instantiate(prefab); //实例化物体
go.transform.position = new Vector3(Random.value * 10, 0, Random.value * 10);//出现时x轴的10个点距离与z轴的10个点距离
yield new WaitForSeconds(3);//等待3秒钟出现下一个物体
} |
|