Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Best way to place GO on top of GO and ignore the bottom one?

Discussion in '2D' started by MatanYamin, Jul 5, 2023.

  1. MatanYamin

    MatanYamin

    Joined:
    Feb 2, 2022
    Posts:
    109
    Hey everyone,

    In my game I'm trying without luck to achieve a simple task.

    Imagine that on top of the whole game screen there's a big square with a collider, and if the player will touch it, it will get detected within OnTrgiggerEnter2D. So far so good.

    My wish is to place another GO on it, but if the player will go through this new GO, the player won't detect the bottom GameObject that the new one is covering and nothing will happend and the OnTriggerEnter2D won't get activated for the big square.

    And by that creating some sort of a "path" or a "tunnel" for the player to go through.
    Again, it is very important not to change the main big square, and only place on top of it new GO for the player to go through.

    Wish I was clear enough.

    Any ideas?
    Thanks!
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,834
    "I have a brick wall but if I paint a black circle on top if it, I want the brick wall to magically behave differently and allow passage without any changes."

    You're going to have to modify something to get new behavior. You can replace the main big square with another that looks just like it but has no collider, or you can disable the collider. The player won't know the difference.
     
  3. MatanYamin

    MatanYamin

    Joined:
    Feb 2, 2022
    Posts:
    109
    Thanks for the answer. The problem is that I do want the player to know if he hits the big square and by that creating some sort of a tunnel. I see from your words that it is physically not supported or not conventional thing to do. I'll look for another approach. Thanks
     
  4. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    you cant ignore the big square, but you can detect that the player entered both squares at the same time
     
    MatanYamin likes this.