Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OnCollisionEnter : MonoBehaviour {
- void Update() {
- }
- void OnCollisionEnter2D (Collision2D col)
- {
- // If the colliding gameobject is an Enemy...
- if(col.gameObject.tag == "Dangerous")
- {
- // Find all of the colliders on the gameobject and set them all to be triggers.
- Collider2D[] cols = GetComponents<Collider2D>();
- foreach(Collider2D c in cols)
- {
- c.isTrigger = true;
- }
- // ... disable user Player Control script
- GetComponent<PlayerControllerScript>().enabled = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement