【发布时间】:2020-06-09 23:52:03
【问题描述】:
我正在开发 unity2D 游戏并且正在实例化预制件,我正在以一种很好的方式生成我的预制件,但问题是当它们生成时我想要它们之间的空间,我的意思是当预制件生成时我想添加空间在它们之间的位置 x,有我的代码:
public class WaveSpawn : MonoBehaviour
{
public GameObject[] easyWaves;
public GameObject[] mediumWaves;
public GameObject[] hardWaves;
public GameObject Player;
// Start is called before the first frame update
void Start()
{
SpawnWave();
}
// Update is called once per frame
void Update()
{
}
public void SpawnWave()
{
float CharacSpeed = Player.GetComponent<charachter>().moveSpeed;
float spacing = 0.1f;
if(CharacSpeed < 11){
Instantiate(easyWaves[Random.Range(0,easyWaves.Length)], new Vector3(gameObject.transform.position.x, gameObject.transform.position.y,0) , Quaternion.identity);
}
else if(CharacSpeed >= 11 && CharacSpeed < 14){
Instantiate(mediumWaves[Random.Range(0,mediumWaves.Length)], new Vector3(gameObject.transform.position.x , gameObject.transform.position.y,0), Quaternion.identity);
}
else if(CharacSpeed >= 14){
Instantiate(hardWaves[Random.Range(0,hardWaves.Length)], new Vector3(gameObject.transform.position.x, gameObject.transform.position.y,0), Quaternion.identity);
}
}
}
有什么帮助吗?请注意,我的预制件生成正确,问题仅在位置 x
【问题讨论】: