• 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 qJake · May 05, 2010 at 12:00 AM · collisionphysics

Physics Accuracy

I have tiny spheres traveling at a reasonable speed (not fast by any means), and I have a series of static mesh colliders in my world. Sometimes, and seemingly at random, the sphere colliders fly straight through the mesh collider, ignoring it completely.

My question is, is there some way to regulate what happens when a smaller collider finds itself "inside" a larger one, or is there a way to make the physics engine more accurate without sacrificing game performance? It would seem that these small spheres are traveling too fast, and "miss" the boundary of the mesh collider completely, passing right through it and out the other side. How can I prevent this?

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

2 Replies

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

Answer by Eric5h5 · May 05, 2010 at 01:46 AM

The physics engine doesn't really do well with tiny objects, so it's better if you scale the spheres up to 1 unit, and scale everything else to compensate. If it's an issue with the spheres being on one side of a collider during one physics frame and on the other side the next physics frame, so that it's not possible for a collision to register, then increase the physics framerate so this has less chance of happening, or use raycasting like this.

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 qJake · May 05, 2010 at 06:23 AM 0
Share

Bampf's answer provided more details, but yours linked directly to a script I intend to try out. You both get upvotes, but you get the answer for posting the link to the script (sorry, Bampf ;) ). Thank you both for the information.

avatar image Bampf · May 05, 2010 at 10:59 AM 1
Share

That's okay, I seem to have gotten some sympathy votes. :-) And I might very well use that script myself. Good stuff.

avatar image
7

Answer by Bampf · May 05, 2010 at 01:47 AM

You can make the Fixed Timestep interval smaller (Edit->Project Settings->Time). That may help, though maybe not 100% of the time, and it could slow your game down.

Another approach is to have your spheres detect collisions explicitly with code. One way would be by firing a ray in the direction of movement to detect things it is about to hit. Given the distance and velocity you can decide what needs to happen.

A third, "quick-fix" technique I once used was to increase the size of the colliders on my small fast-moving objects. Specifically, the collider was a capsule that started at front edge of my object, and extended backwards well past the back edge. So even if the object travelled through a mesh between frames, the collider "tail" would still hit.

(Not sure I recommend that last approach; there will always be a slow machine or situation that it doesn't catch. Conversely, moving meshes may hit the collider after the bullet-object already passed, leading to a false collision. But I mention it because it may give you ideas, and in my case I was able to tune it to the point where problems were quite rare, and hard to spot when the action was quick.)

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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Shaking physics body container while preventing penetration 1 Answer

HELP!! OnCollisionEnter is not working when i built it out on IPHONE! 0 Answers

is there a way to move a rigidbody with something like moveposition without clipping through collider? 1 Answer

overlapsphere to destroy NPCs on exit 1 Answer

unity3d is meter units? meter to cm 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