Advertisement
Guest User

New Script

a guest
Apr 26th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. public class OnCollisionEnter : MonoBehaviour {
  2.  
  3.  
  4.     void Update() {
  5.        
  6.     }
  7.        
  8.  
  9.     void OnCollisionEnter2D (Collision2D col)
  10.         {
  11.             // If the colliding gameobject is an Enemy...
  12.             if(col.gameObject.tag == "Dangerous")
  13.             {
  14.                
  15.                 // Find all of the colliders on the gameobject and set them all to be triggers.
  16.                 Collider2D[] cols = GetComponents<Collider2D>();
  17.                 foreach(Collider2D c in cols)
  18.                 {
  19.                     c.isTrigger = true;                                                                                                                  
  20.                 }
  21.                
  22.                 // ... disable user Player Control script
  23.                 GetComponent<PlayerControllerScript>().enabled = false;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement