Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < gp.position.x)
        {
            platformDist = Random.Range(pdMin, pdMax);

            platformSelect = Random.Range(0, op.Length);

            heightDiff = transform.position.y + Random.Range(maxHeightDiff, -maxHeightDiff);

            if (heightDiff > maxHeight)
            {
                heightDiff = maxHeight;
            }
            else if (heightDiff < minHeight)
            {
                heightDiff = minHeight;
            }

            transform.position = new Vector3(transform.position.x + (randPlatformWidth[platformSelect] / 2) + platformDist, heightDiff, transform.position.z);

            GameObject newPlatform = op[platformSelect].GetPooledObject();
            newPlatform.transform.position = transform.position;
            newPlatform.transform.rotation = transform.rotation;
            newPlatform.SetActive(true);


            if (Random.Range(0f, 100f) < randCoinThreshold)
            {
                cg.CreateCoins(new Vector3(transform.position.x, transform.position.y + 3f, transform.position.z));
            }

            transform.position = new Vector3(transform.position.x + (randPlatformWidth[platformSelect] / 2), transform.position.y, transform.position.z);
        }
    }