Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        Vector3 spawnPosition     = startPoint.position;
        int     tunnelNoObstacles = tunnelNoObstacle;

        for (int i = 0; i < tunnelPreSpawn; i++)
        {
            spawnPosition -= tunnelPrefab.startPoint.localPosition;
            Objects spawnedTunnel = Instantiate(tunnelPrefab, spawnPosition, Quaternion.identity) as Objects;
            if (tunnelNoObstacles > 0)
            {
                tunnelNoObstacles--;
            }
            else
            {
                spawnedTunnel.Activate();
            }

            spawnPosition = spawnedTunnel.endPoint.position;
            spawnedTunnel.transform.SetParent(transform);
            spawnedTunnels.Add(spawnedTunnel);
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (mainCamera.WorldToViewportPoint(spawnedTunnels[0].endPoint.position).z < 0)
     {
         Objects tunnelOne = spawnedTunnels[0];
         spawnedTunnels.RemoveAt(0);
         tunnelOne.transform.position = spawnedTunnels[spawnedTunnels.Count - 1].endPoint.position -
                                        tunnelOne.startPoint.localPosition;
         tunnelOne.Activate();
         spawnedTunnels.Add(tunnelOne);
     }
 }