Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
8
Question by aristaios · Jan 05, 2014 at 05:41 PM · 2dcollisionphysicscollidersfixedupdate

2D Collider aren't exact?

I have a character with a Rigidbody2D and I am moving him in the FixedUpdate method by adding forces. Yet it seems that he sometimes get stuck on a "ledge" were technically no ledge is. He has a BoxCollider2D as well a the ground.

You can clearly see the collider aren't touching yet the physics engine leaves him stuck there! The ground boxes are perfectly aligned via vertex snapping and the character started a bit above the ground to prevent him from going inside there.

Failing Colliders

What can I do to prevent this from happening? I mean sure I could implement a jump, but who would want to jump over a ledge on a seemingly flat surface?

Thanks in advance!

fail.png (4.6 kB)
Comment
Add comment · Show 11
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 aristaios · Jan 05, 2014 at 06:40 PM 0
Share

Should I file a bug report in the issue tracker?

avatar image fafase · Jan 05, 2014 at 06:44 PM 0
Share

We only see the collider of that object, and it is way bigger than the actual object. What about the collider it is colliding with? Are you sure it is exactly the shape of the other objects?

avatar image aristaios · Jan 06, 2014 at 02:30 PM 0
Share

It isn't bigger; I unfortunately took the screenshot during the animation. The collider in the top right is a good bit smaller than the sprite and the collider it seems colliding with is seen as the green lines in the bottom left. There is quite a gap between those.

avatar image aristaios · Jan 07, 2014 at 09:57 PM 0
Share

So any ideas on this?

avatar image aristaios · Jan 08, 2014 at 02:58 PM 1
Share

Here is a screenshot of what I was able to reproduce: reproduced Also there is a download for the project in which this occurs: http://www.filedropper.com/newunityproject. Just unzip it, open it, click play and then move the top quad to the right. You will see it gets stuck on a non-existant ledge.

reproduced.png (10.6 kB)
Show more comments

6 Replies

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

Answer by Invertex · Jan 18, 2014 at 11:08 AM

Just thought I'd stop by and say I sorta found out the answer to this. The issue is that while the first collider you're on decides that you should be pushed out of it upwards, the collider you start going over next sees that you're more on side of it then the top and decides the shortest path to push you out of the collider is backwards, so you get stopped. The solution seems to be to use Edge colliders to build your surface instead. Make your cube out of them and it seems to work perfectly! (plus you can then define the sides as the Wall layer and the top as the Ground, simplifying level design even more.

MelvMay pointed it out in this thread: http://forum.unity3d.com/threads/223054-BoxCollider2D-colliding-with-EdgeCollider2D?p=1488478&viewfull=1#post1488478

Including a useful link about the issue. https://www.iforce2d.net/b2dtut/ghost-vertices

Comment
Add comment · 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
7

Answer by idhanu · Mar 31, 2016 at 12:43 PM

@Invertex try fiddling with Min Penetration For Penalty value found in Edit->Project Settings->Physics 2D. A lower value of 0.001 rather than 0.01 fixed the problem for me.

Comment
Add comment · Show 2 · 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 Invertex · Apr 19, 2018 at 09:47 AM 0
Share

Indeed, that is the proper solution now. That option didn't exist before Unity 5.0. This post was made back around Unity 4.2 days.

avatar image victoroliveirab · Jul 03, 2018 at 11:27 AM 3
Share

I was googling around because had the same issue. This property is now obsolete and we should now be lowering Physics2D.defaultContactOffset. Same path though, Edit -> Project Settings -> Physics 2D and then "Default Contact Offset"

avatar image
3

Answer by Nabeel Saleem · Jun 26, 2014 at 09:18 PM

You can use third part plugin i found its effective to reduce draw call. 2d concave collider

Comment
Add comment · 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
1

Answer by Jinxology · Jan 08, 2014 at 12:25 AM

Use a sphere collider on the bottom of your character, rather than a box. That way he will roll up little bumps like that. You could also put a box collider on him to account for his body and head collisions.

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 aristaios · Jan 08, 2014 at 02:51 PM 0
Share

I know about circle colliders and that's what I have done for now, yet it doesn't make up for the existing problem! But still thanks for the answer :)

avatar image
0

Answer by FirePlantGames · May 08, 2014 at 11:08 PM

Try set the camera to orthographic instead of perspective if you haven't

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 Invertex · May 08, 2014 at 11:27 PM 1
Share

That has nothing to do with the issue here. And the answer was already found and chosen ;)

  • 1
  • 2
  • ›

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

28 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

Related Questions

Collision detection for many colliders 0 Answers

Is it required to use 3D physics when a 2D game uses the z axis? 1 Answer

Rigidbody2D characters push each other 0 Answers

Precise Collision Detection 0 Answers

[2D] Getting particles to collide with a game object(Explosion debris effect) 0 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