level generator Unity2D
Hi, i was making a platformer level generator and for some reason whenever i generate the new platforms they dont load in properly, they are there but you cant see them on the game window. this is my first time using the forum so im not really sure how ask for help.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Generator : MonoBehaviour { public GameObject thePlatform; public Transform generationPoint; public float distancebetween; public GameObject[] thePlatforms; private int platformSelector; public float platformNumber; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if(platformNumber >= 0 && transform.position.x < generationPoint.position.x) { transform.position = new Vector3(transform.position.x + distancebetween, transform.position.y, transform.position.z); platformSelector = Random.Range(0, thePlatforms.Length); Instantiate(thePlatforms[platformSelector], transform.position, transform.rotation); platformNumber --; } } }
Answer by Cuttlas-U · Apr 29, 2020 at 05:22 AM
hey ; there is an option to send the codes ; otherwise your code would be messy , so use it ;
but your problems i think about the "Z" value of your created platform ; so its outside of camera range ; try changing it ;
Your answer
Follow this Question
Related Questions
Randomly generated content? 1 Answer
How to automatically generate a new int with a specific name? 1 Answer
Generate 2d star background 0 Answers
Creating a grid on top of a terrain 0 Answers