Kelvineger

Spawn Controller

Jun 18th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class preFab : MonoBehaviour {
  5.  
  6.     public GameObject barreiraPrefab;
  7.     public float rateSpawn;
  8.     public float currentTime;
  9.  
  10.  
  11.     // Use this for initialization
  12.     void Start () {
  13.         currentTime = 0;
  14.     }
  15.    
  16.     // Update is called once per frame
  17.     void Update () {
  18.         currentTime += Time.deltaTime;
  19.         if (currentTime >= rateSpawn)
  20.         {
  21.             currentTime = 0;
  22.             GameObject tempPrefab = Instantiate(barreiraPrefab) as GameObject;
  23.             tempPrefab.transform.position = new Vector3(transform.position.x, tempPrefab.transform.position.y, tempPrefab.transform.position.z);
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment