Advertisement
dnnkeeper

Unity Decay

Mar 16th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4.    
  5. public class Decay : MonoBehaviour {
  6.    
  7.     public float time_ms = 1000.0f;
  8.     private float TimeToDie = 0.0f;
  9.    
  10.        
  11.     // Use this for initialization
  12.     void Start () {
  13.         TimeToDie = Time.time + time_ms/1000.0f;
  14.     }
  15.    
  16.     // Update is called once per frame
  17.     void Update () {
  18.         if (TimeToDie != 0.0f && Time.time > TimeToDie)
  19.         {
  20.             Destroy(gameObject);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement