can somebody help me?

I have a 2D game in Unity which contains 2 ground objects, one above the other and that game also has a character. I want the character to be able to fly from one to the other, so if I press a UI button the character will fly down and if I press another UI button the character will fly up. Both of the grounds have box colliders, and I want to have the down UI button only accessible when I'm at the upper ground and the up UI button when I'm at the lower ground. so basically the character can go through the upper ground if I press the down UI button and when I'm at the lower ground the character can fly up to the upper ground and when the character is above the upper ground the box collider of the upper ground reappers.

what did you try already? can you share some code?

  • If a character is grounded (you must know it touched a floor) and you press a button to lower ground you start a function JumpOff.
  • Function JumpOff needs to turn on Is Trigger on Collider2D of the character so he passes the floor.
  • Now you need to know when the character stops passing the floor. You can use OnTriggerExit2D to turn off Is Trigger.


Use circleCasts to see if your character is touching the ground, I'm relatively new to unity as well but I understand that if they overlap with something on the correct layer than they will constantly send out a trigger


The Collider2D ignore layers. Objects dont have to be on a same layer. If you turn on Is Trigger it will become like transparent and will pass everything.