生成的多维数据集没有朝目标Win Cube的方向生成

我正在尝试生成红色的多维数据集,使其朝着黄色的多维数据集前进,但是它们不断朝着自己的方向生成。 我将多维数据集编码为只能在x和z方向上生成,现在的挑战在于如何生成朝向黄色的多维数据集。

public class WaySpawner : MonoBehaviour
{
    [SerializeField] int PlatformNumber = 15;

    public GameObject Way;

    Vector3 lastPos;

    float size;

    // Use this for initialization
    void Start()
    {
        // Need to Consider if this Code Will Stay.......!
        lastPos = Way.transform.position;

        size = Way.transform.localScale.x;

        for (int i = 0; i < PlatformNumber; i++)
        {
            SpawnPlatforms();
        }
    }

    public void startSpawningPlatforms()
    {
        InvokeRepeating("SpawnPlatforms",0.1f,0.1f);
    }

    // Update is called once per frame
    void Update()
    {



    }

    void SpawnPlatforms()
    {

        int rand = Random.Range(0,6);

        if (rand < 3)
        {
            SpawnX();

        }

        else if (rand >= 3)
        {

            SpawnZ();

        }
    }

    void SpawnX()
    {
        Vector3 pos = lastPos;

        pos.x += size;

        lastPos = pos;

        Instantiate(Way,pos,Quaternion.identity);

        int rand = Random.Range(0,5);

    }

    void SpawnZ()
    {
        Vector3 pos = lastPos;

        pos.z += size;

        lastPos = pos;

        Instantiate(Way,5);

    }
}

生成的红色多维数据集应朝黄色多维数据集的方向生成标题,并且不应越过它。参见image

dominick86814082 回答:生成的多维数据集没有朝目标Win Cube的方向生成

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3128371.html

大家都在问