How To Make An Invisible Wall That's Impossible To Get Out Of?

Hello once again awesome people of Unity answers. I have a question that’s out of wanting to do it, and curiosity. You see, I want to make an invisible wall that my Player cannot pass through no matter what, but I don’t know an effective way of doing that. So far, I use an invisible box collider 2D, and for the most part it seems to do the job. However, recently I’ve been able to glitch through it and while it doesn’t break the game, it does cause me to die. I would just like to avoid dying like that you see. Anyways my box collider 2D isn’t really that big, but could that be the reason why I can glitch through it? Or is it another reason? By the way, I’m not the only one who can glitch through box colliders. My Ai can also do it. As a matter of fact it does it all the time. So what can I do? I would love to hear anyone’s thoughts/advice.

Fast moving objects and thin colliders is a well know issue. Some options to consider

  • Slowing down
  • Thicker colliders
  • Changing the collision mode on the RigidBody
  • Ignoring physics and using scripts to constrain position
  • Reducing the physics time step

Edit: Added further solutions from comments.