Advertisement
Guest User

Untitled

a guest
Aug 9th, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  35.  
  36. using UnityEngine;
  37. using System.Collections;
  38.  
  39. public class AddForceOnCollision : MonoBehaviour {
  40.    
  41.     public float force = 10.0f;
  42.     public float collisionDelay = 1.0f;
  43.    
  44.  
  45.     void OnCollisionEnter (Collision other)
  46.     {  
  47.         if (other.gameObject.tag.Contains("Player"))
  48.         {
  49.             other.rigidbody.AddForce (other.contacts[0].normal * force * -1.0f, ForceMode.Impulse);
  50.            
  51.             other.gameObject.SendMessage("GrenadeMoveDelay");
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement