hello all
i have problem now
that my script should spawn 2 kind of prefabs randomly
but that is never happened
why ?
As you can see there is 2 elements
and the output is just Road1
can i know why
and that is the spawn script !
using UnityEngine;
using System.Collections;
public class SpawnRoad : MonoBehaviour {
public GameObject [] obj ;
public float spawnmin = 1f ;
public float Spawnmax = 2f ;
private bool x ;
// Use this for initialization
void Awake ()
{
x = true ;
}
// Update is called once per frame
// Use this for initialization
void Update() {
if(transform.position.z % 500 == 0 )Spawn () ;
}
void Spawn ()
{
Instantiate(obj[Random.Range(0,0)],transform.position, Quaternion.identity) ;
//Invoke("Spawn",8 ) ;
}
}
//
//using UnityEngine;
//using System.Collections;
//
//public class SpawnScript : MonoBehaviour {
// public GameObject [] obj ;
// public float spawnmin = 1f ;
// public float Spawnmax = 2f ;
//
//
// // Use this for initialization
// void Start () {
// Spawn() ;
// }
//
// void Spawn ()
// {
// Instantiate(obj[Random.Range(0,obj.GetLength(0))],transform.position, Quaternion.identity) ;
// Invoke("Spawn",Random.Range(spawnmin , Spawnmax )) ;
//
//
// }
//}