Advertisement
toko214

platform

Mar 22nd, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class colliding : MonoBehaviour {
  6.  
  7.     public BoxCollider2D trigCollider;
  8.     public BoxCollider2D solidCollider;
  9.     public BoxCollider2D playerCollider;
  10.  
  11.     void Start () {
  12.         playerCollider = GameObject.Find("playerSprite2").GetComponent<BoxCollider2D>();
  13.         Physics2D.IgnoreCollision(trigCollider, solidCollider, true);
  14.     }
  15.  
  16.     void OnTriggerEnter2D(Collider2D other)
  17.     {
  18.         if (other.gameObject.tag == "Player")
  19.         {
  20.             Physics2D.IgnoreCollision(playerCollider, solidCollider, true);
  21.         }
  22.     }
  23.     void OnTriggerExit2D(Collider2D other)
  24.     {
  25.         if (other.gameObject.tag == "Player")
  26.         {
  27.             Physics2D.IgnoreCollision(playerCollider, solidCollider, false);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement