Advertisement
Guest User

Untitled

a guest
Aug 9th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ExpandAndDie : MonoBehaviour {
  5.    
  6.     public float growTime = 0.15f;
  7.     public float initialRadius = 1.0f;
  8.     public float finalRadius = 4.0f;
  9.    
  10.    
  11.     void Start ()
  12.     {
  13.         StartCoroutine(GrowAndDie());
  14.     }
  15.    
  16.    
  17.     IEnumerator GrowAndDie ()
  18.     {
  19.         float t = 0.0f;
  20.         Vector3 initialSize = new Vector3(initialRadius, initialRadius, initialRadius);
  21.         Vector3 finalSize = new Vector3(finalRadius, finalRadius, finalRadius);
  22.        
  23.         while (t < growTime)
  24.         {
  25.             transform.localScale = Vector3.Lerp(initialSize, finalSize, t/growTime);
  26.             t += Time.deltaTime;
  27.             yield return null;
  28.         }
  29.         Destroy(gameObject);
  30.     }
  31. }
  32.  
  33.  
  34. using UnityEngine;
  35. using System.Collections;
  36.  
  37. public class AddForceOnCollision : MonoBehaviour {
  38.    
  39.     public float force = 10.0f;
  40.     public float collisionDelay = 1.0f;
  41.    
  42.  
  43.     void OnCollisionEnter (Collision other)
  44.     {  
  45.         if (other.gameObject.tag.Contains("Player"))
  46.         {
  47.             other.rigidbody.AddForce (other.contacts[0].normal * force * -1.0f, ForceMode.Impulse);
  48.            
  49.             other.gameObject.SendMessage("GrenadeMoveDelay");
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement