Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by THEAK472009 · Oct 17, 2016 at 10:29 PM · physics2dcollider2dstuck

How to avoid Rigidbody collider from getting stuck between walls

Hello! I have a 2D physics problem where a RigidBody2D BoxCollider2D which is set to never sleep and continuous collision detection gets stuck between two static colliders. Setting the rigidbody collision detection mode to discrete solves the problem but we have mechanics which involve stacking boxes on top of each other and using discrete collision detection the stack of boxes will most often collapse.

I have tried using rounded corners, use frictionless material, use edge colliders for everything, use crazy gravity values like 1000 but the box still gets stuck between the walls.

The scale of the colliders is unit size and their physics material is frictionless. Also the gap between the two highlighted black walls is 1 unit so the collider should pass through the gap.

This is the only remaining major issue which is giving us a lot of trouble while doing level design. Right now our only solution is to increase the gap by slightly offsetting the colliders but this is not a viable solution in all situations. Any kind of help will be really appreciated.

Thank you.

alt text

screen-shot-2016-10-17-at-31358-pm.png (106.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by YesNoKonrad · Oct 18, 2016 at 01:34 AM

Well this is only logical.

Think of it: If your boxes, tiles and gaps are exactly 1 unit wide and a box and a gap are exactly aligned, the outer x-bounds of the collider of the box exist at the same position as the tile-bounds surrounding the gap. No matter the friction: since the collider-lines align, a collision is registered.

No choice (except there is) than to reduce the box's collider size by a miniscule amount. I recommend at least 4% collider-size- reduction. You will see this in every game in existence that the boxes are smaller than the tiles the level is built off.

You should also probably adjust the sprite, however leave the transform at normed scale. Just to be sure. Unity loves to do weird stuff on its own. Let's don't give it any more reason to do so.

Another solution, by the way, is to make the box-collider into trigger and write your own gravity handling function. Whenever the trigger function is called you observe the relative movement of the two involved objects and make a decision based on that.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image THEAK472009 · Oct 18, 2016 at 02:29 AM 0
Share

I never thought of the second solution even though I thought about writing grid based collision but this is even better. Thanks man!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

60 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to rotate a 2d collider in 3d? 0 Answers

My OnCollisionEnter says i have 128 Collisions every collision 1 Answer

Stuck Between tilemap colliders 0 Answers

problem solving ghost vertices with trigger and collision colliders 0 Answers

Unity 2D game: all colliders not working 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges