Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class colliding : MonoBehaviour {
- public BoxCollider2D trigCollider;
- public BoxCollider2D solidCollider;
- public BoxCollider2D playerCollider;
- void Start () {
- playerCollider = GameObject.Find("playerSprite2").GetComponent<BoxCollider2D>();
- Physics2D.IgnoreCollision(trigCollider, solidCollider, true);
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- if (other.gameObject.tag == "Player")
- {
- Physics2D.IgnoreCollision(playerCollider, solidCollider, true);
- }
- }
- void OnTriggerExit2D(Collider2D other)
- {
- if (other.gameObject.tag == "Player")
- {
- Physics2D.IgnoreCollision(playerCollider, solidCollider, false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement