Hi !
I’m currently creating a 2D runner game.
Well I wanted to create a C# script which generate obstacles (2 differents types (for instance big square of small square) : 2 prefabs) from a point (the span empty object) each (randomRange from 0 to 5 seconds).
I’m stuck this is my code :
using UnityEngine;
public class GenerateObstacle : MonoBehaviour {
public GameObject obstacles;
void Start(){
}
void Update(){
Invoke("GenerateNewObstacle" , Random.Range(5,12));
}
void GenerateNewObstacle()
{
Instantiate(obstacles);
}
}
Thanks for your help !
