Advertisement
Selzier

Untitled

Feb 20th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpawnItem : MonoBehaviour {
  5.  
  6.     public GameObject prefabToInstantiate;
  7.  
  8.     // Use this for initialization
  9.     void Start () {
  10.         StartCoroutine(SpawnAfterSeconds(1f));        
  11.     }
  12.    
  13.     IEnumerator SpawnAfterSeconds(float delay) {
  14.         yield return new WaitForSeconds(delay);
  15.  
  16.         Vector3 randomSpawn = new Vector3(Random.Range(0, 5), Random.Range(0, 5), Random.Range(0, 5));
  17.  
  18.         Instantiate(prefabToInstantiate, randomSpawn, Quaternion.identity);
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement