Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by _foa · Feb 26, 2015 at 01:39 PM · 2d2d-physics

Why Box Colliders 2D does not touch ?

Hello everybody,
I was playing around with Unity 2D physics engine and I was wondering why the colliders slightly float upon each other.

Here is what I'm talking about (Scene view while the game is running):

alt text

As you can see the Blue square floats above the Yellow rectangle altough the physics engine acts as they are colliding.

The Blue square has a Rigidbody 2D and a Box Collider 2D while the Yellow rectangle has just a Box Collider 2D and everything has the Transform scale set to X: 1, Y: 1, Z: 1, the Blue square sprite has a size of 32x32 pixels and the Yellow rectangle sprite has a size of 128x16 pixels.

I've made a project from scratch just to test this, so everything I am using has its default values, even the sprites have been imported with Unity default values (Pixels per Unit: 100).
I'm using Unity 4.6.2f1

Is there something I am doing wrong ? Is it fixable or is this working as designed ?

Thank you for your help !

floating.png (23.2 kB)
Comment
Add comment · Show 6
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 Josh Naylor ♦♦ · Feb 26, 2015 at 02:16 PM 0
Share

Can i see the inspector of the blue square to check the rigidbody2d?

avatar image _foa · Feb 26, 2015 at 02:26 PM 0
Share

There you have it !
The Blue square is on the left, the Yellow rectangle is on the right !

alt text

props.png (23.7 kB)
avatar image Josh Naylor ♦♦ · Feb 26, 2015 at 02:32 PM 0
Share

I built the same thing in same version and it works fine, try this. http://1drv.ms/1BgLn$$anonymous$$C. If $$anonymous$$e doesn't work, send me yours.

avatar image _foa · Feb 26, 2015 at 02:36 PM 0
Share

Thank you for your quick response ! If in your project you zoom in at the rocky square you can see that they are floating too.

avatar image Josh Naylor ♦♦ · Feb 26, 2015 at 02:48 PM 1
Share

Very true, when zoomed in so far in scene view, but in game view my camera does not pick this up. This will be due to the automatically applied box collider, if you want it to be pixel perfect when zoomed in that much you will have to edit the collider slightly. http://gyazo.com/81e69589c09f5c32a794d288b6090f36

Show more comments

1 Reply

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

Answer by SirMalarkey · Feb 26, 2015 at 02:49 PM

This error is do to the way the physics engine works, if you adjust the bounds of your box collider to be slightly smaller than your sprite. It will not be noticeable.

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 _foa · Feb 26, 2015 at 03:04 PM 0
Share

I see, thank you for your quick response.
I'm having much less empty space just by reducing the collider size by 0.01 so I understand that this works as intended and needs just some manual fine tuning.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how to make a 2d character three-dimensional? 1 Answer

2D random shooting problem with velocity, 0 Answers

Dash towards cursor 1 Answer

Unity 2D Bend Sprites between HingeJoint2D 1 Answer

Diagonal movement 1 Answer


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