Hi All, I’m working a basic jump type game and I was wondering how I would get started with procedural generation . Can I just buy an asset for this , so far I have everything working except i’m actually designing all of the levels . .
Note: This is supposed to be a very short project , so nothing too difficult,
Word, I might write my own solution though , right now I already have it set up to enable or disable one of 3 objects per- row object and i can just instate once with each object( as well as deleted game objects after the user passes them )
Here’s the solution I’ve come up with thus far, probaly gonna fix it to delete itself based on a no-longer visable rather then a simple time delay , anyway , enjoy
using UnityEngine;
using System.Collections;
public class Gen : MonoBehaviour {
public float Y = 30 ;
public bool Spawn = true ;
public GameObject NewLane;
public float life = 15 ;
public float delay = 3 ;
private GameObject B ;
void Start () {
//B = GameObject.Find("SpawnOn");
StartCoroutine(Go());
}
IEnumerator Go() {
// if ( B.active == false) {
//Spawn = false;
//}
yield return new WaitForSeconds (delay);
if (Spawn == true) {
GameObject clone;
clone = Instantiate(NewLane, (transform.position + new Vector3(0,Y,0)), transform.rotation) as GameObject;
//clone.velocity = transform.TransformDirection(Vector3.forward * 10);
yield return new WaitForSeconds (life*2);
// or just put a number here
Destroy(gameObject);
}
}
}
And the object i’m spawning have their own script which basically tells them to have one of 3 modes, selected at random . I plan on finishing this short little game this weekend .
Its actually pretty fun so far, uploading a demo to WIP soon !