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
1
Question by oscarlosu · Mar 12, 2017 at 04:35 PM · physicspenetration

Compute Penetration with off-center colliders

I'm trying to use the newly exposed ComputePenetration function in Unity 5.6.0b9. It seems to work as expected when the involved colliders are centered on the game object's origin, but I'm getting strange results when testing with colliders that are not centered in their object's origin when the object has a rotation and a scale.

The image below shows one of the situations where Physics.ComputePenetration doesn't seem to work. The yellow line shows the depenetration direction using the center of the collider and the red line shows the depenetration direction using the transform position of the collider (as shown in the Unity Docs).

Example screen capture of problematic image

Find the whole setup in a Unity Package here.

computepenetrationtest.zip (75.0 kB)
computepenetrationcap.png (182.9 kB)
Comment
Add comment · Show 2
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 oscarlosu · Mar 13, 2017 at 11:44 AM 0
Share

I have updated the attached unity package with the fix I mentioned in my reply.

avatar image hippocoder · Jul 02, 2017 at 01:28 PM 0
Share

Having problems in 2017.1 f0 with this. Not fixed vs tall level colliders which are offset from y = 0

1 Reply

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

Answer by oscarlosu · Mar 13, 2017 at 11:38 AM

Followed a suggestion in the Unity Forums by @recursive and got good results. The idea is this:

  • Save collider centers

  • Set collider centers to zero

  • ComputePenetration with extracted center positions (they are in local space in the collider)

  • Reset collider centers

This should probably be done internally by Physics.ComputePenetration, but it seems to be a good fix for now. I have tested it with all the 3D collider types and it seems to work, with the exception of the TerrainCollider.

Comment
Add comment · Show 3 · 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 oscarlosu · Mar 13, 2017 at 02:07 PM 0
Share

This issue has been confirmed as a bug, to be fixed in the next released version of Unity.

avatar image judgementAlex · Apr 06, 2017 at 03:52 AM 0
Share

having the same issue. glad to see it's a bug and not me going crazy. decided to resolve by generating convex mesh colliders, but will follow the @recursive workaround if I run into any issues.

do you have a tracking number for the bug report?

avatar image oscarlosu judgementAlex · Apr 06, 2017 at 09:09 AM 0
Share

It wasn´t made into a new ticket because they were already aware of the problem. It is supposed to be fixed now in 5.6, although I haven't verified myself. I did however discover the same problem with the relate method Collider.ClosestPoint(Vector3 position). Likely also an issue with Physics.ClosestPoint(...).

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

99 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 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

Penetration based on shape 0 Answers

2D 360 degress platformer example needed 0 Answers

Actual collision happens before the visual collision 0 Answers

Why is my stack of cubes vibrating, creeping, and penetrating? 5 Answers

Physics Possibilities?: Angles, Penetration, Exceptions 4 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