Question by
Zedespook · May 29, 2018 at 09:34 PM ·
physics2dcollision2dordering
Is there a way for a game object to ignore collision if there is an object above the collision object?
Okay, yeah I get it, my question is a bit complicated, although I didn't find a better way to ask this question.
I need help with my project because I can't come up with a solution to a simple issue (I mean I think it should be simple).
Since the header question is kind of foggy about the subject that I'm trying to ask I'm going to visualize it:
I want to go through here, but there is a wall under it. (No removing it from the game isn't a fix, I need that wall.)
So my question is, is there a way for the Player to get through that exit if there is a collided area under it. I tried to use this code, but for some reason, the layer wouldn't get destroyed...
public class PathDestroy : MonoBehaviour
{
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "PathBlock")
{
Destroy(collision.gameObject);
}
}
}
screenshot-from-2018-05-29-23-11-51.png
(194.4 kB)
screenshot-from-2018-05-29-23-12-51.png
(164.5 kB)
Comment