【发布时间】:2020-08-11 07:52:33
【问题描述】:
如何使 prefab2 在高于 prefab1 的 y 处实例化。它们是从同一位置随机生成的。代码:
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Time.time > nextSpawn)
{
what = Random.Range(1, 3);
Debug.Log(what);
switch (what)
{
case 1:
Instantiate(prefab1, transform.position, Quaternion.identity);
break;
case 2:
Instantiate(prefab2, transform.position.y, Quaternion.identity);
break;
}
nextSpawn = Time.time + SpawnRate;
}
}
}
抱歉,我知道解决方案可能很简单,但我就是找不到。
【问题讨论】:
-
看看
Vector3是如何工作的:docs.unity3d.com/ScriptReference/Vector3.html
标签: c# visual-studio unity3d