我正在尝试为iPhone制作一款小游戏,这是一种简单的游戏机制,其中某些平台会在90 degrees
中的-90 degrees
,0 degrees
或y rotation
生成。
它应该在平台之间产生空间或间隙。
大约一半的时间。其中一半有空位而其他人没有空位。
这是我的脚本。你不需要重新输入整个东西。对不起,如果它马虎。
public class General : MonoBehaviour
{
public int time;
public int timeLev;
public int speed = 7;
public GameObject platformTypeOne;
public float platPosx;
public int ran;
public float platLegnth;
public int[] platRotationSel = new int[] { 0, 90, -90};
public int platRotation;
void Start()
{
StartCoroutine("PlatSpawn");
}
void Update()
{
time = (int)(Time.time % 1000000f);
speed = time / 3;
platRotation = platRotationSel[Random.Range(0, 3)];
Debug.Log(platRotation.ToString());
}
IEnumerator PlatSpawn()
{
while (true)
{
if (platRotation == 90 || platRotation == -90)
{
platLegnth = 2.5f;
}
else
{
platLegnth = 5f;
}
ran = Random.Range(0, 4);
platPosx = platPosx + platformTypeOne.transform.position.x + platLegnth;
Instantiate(platformTypeOne, new Vector3(platPosx, 0, 0), transform.rotation);
yield return new WaitForSeconds(0.5f);
if (platRotation == 90 || platRotation == -90)
{
platLegnth = 2.5f;
}
else
{
platLegnth = 5f;
}
ran = Random.Range(0, 4);
platPosx = platPosx + platformTypeOne.transform.position.x + platLegnth;
Instantiate(platformTypeOne, new Vector3(platPosx, 0, 0), Quaternion.Euler(new Vector3(0, platRotation, 0)));
yield return new WaitForSeconds(0.5f);
}
}
}