- Home /
Question by
akashsunny · Feb 18, 2014 at 04:45 PM ·
spawnarrays
Unable To spawn Multiple Objects
using UnityEngine; using System.Collections;
public class SpawnScript : MonoBehaviour { public float time; public static int size; private int prop_Number; public float ModValue; public Object[] Spwan_props = new Object[size] ;
// Use this for initialization
void Start ()
{
InvokeRepeating("spawnArandomProp" , 0.2f , time);
}
void spawnArandomProp()
{
prop_Number = Random.Range( 0,1);
ModValue*=-1;
transform.position = new Vector3(Random.Range(-6,6)+ModValue , 5,0);
Instantiate(Spwan_props[prop_Number] , transform.position , Quaternion.identity);
}
}
Comment