Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Scrolling level Instantiate after cycle

$
0
0
When I run my level in generates 10 obstacles, similar to Mario pipes. these then scroll across the level and finish about position.x 9000, I need my script to generate some more at that point and destroy the previous ones, to make the level infinite . at the minute obstacle is a prefab and X is the amount of pipes to spawn at start. using UnityEngine; using System.Collections; public class levelgeneration : MonoBehaviour { public GameObject obstacle; public float x = 1; public float moveSpeed = 0.03f; void Update () { transform.position += new Vector3(5, 0, 0); float y = Random.Range(-27.1157f, -18.05732f); if(x < 15) { Instantiate(obstacle, new Vector3(x * 12.0f, y, 0),Quaternion.identity); x++; } if (transform.position.x > 9000) { } } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>