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
0
Question by Ted-Brown · Sep 12, 2012 at 05:57 AM · collisionphysicsrigidbodycolliderbug

No bounce after rigidbody collision

I am seeing a common issue: a rigidbody passing through a collider that previously worked perfectly. I've tried many common solutions as well, but now I'm just confused. When I saw the rigidbody triggering an OnCollisionEnter event as it passed through the collider, I pretty much gave up!

Who the f--k said breakout clones were easy? =D

I am trying to understand why this is happening, and how to solve this issue without hackery. I just want the ball to bounce, on and on and on.

Additional data:

  • The "ball" is a cube. It's a rigidbody. All rotation is disabled. Movement on the Z axis is disabled.

  • All walls are orthogonally aligned colliders. They are as wide as the ball on the axis they will hit it on.

  • Both the ball and walls have a physics material with zero friction and a bounciness of 1. (in other words, it should bounce for infinity)

  • When the ball "escapes," its position has always passed the wall's position, on the axis of intended reflection. The ball's previous position is always on the other side of the wall.

Solutions attempted:

  • I cranked Fixed Timestep down to 0.01. This just made it take longer for the issue to appear.

  • I set Maximum Allowed Timestep to 0.05

  • I used the DontGoThroughThings script on the Wiki (casts a ray using the collision extents from the previous position)

  • Rigidbody Collision Detection set to Continuous (and everything else at some point)

Solutions I'd like to avoid:

  • Making walls freaking ginormous (I need the collision to be bulletproof for objects in the actual field of play)

  • Slowing down the ball (lame)

Who's got the juice?

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 Ted-Brown · Sep 12, 2012 at 06:01 AM 0
Share

Wait... holy crap, is it bouncing off the other side of the collider???

avatar image Strategos · Sep 12, 2012 at 09:48 AM 0
Share

Im making a game where the player moves VERY fast and the UNITY collision simply cant handle it (which is pretty unforgivable for a collision system).

I had to use the "dont go through walls" idea by raycasting and moving the character back to last position if it went through the mesh. BUT that sometimes meant the object just got stuck forever at "last Position", if the collision warning occurs for a second frame I subtract 10% the objects last distance travelled in a frame.

Yes it's a bit hacky but it does resolve the problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by svenskefan · Sep 12, 2012 at 07:55 AM

Hi! I would try making the colliders wider/thicker.

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 Ted-Brown · Sep 13, 2012 at 03:03 AM 0
Share

Sorry, I am looking for a general case solution, not a specific fix for the ball going out of bounds. I have to ensure that collision will work with any reasonably sized object, not just walls that can be relatively infinite in size.

But if I was just concerned about going out of bounds, that would be an ideal, practical fix.

avatar image Fattie · Sep 13, 2012 at 05:12 AM 0
Share

the general case solution is that colliders are meant to be wide enough to be wider than one frame of movement.

that's how they are meant to work.

I think, a number of people have already explained that you just use the layers system to make "invisible" so to speak colliders (all colliders are invisible) so they fit in the scene

you should also note that game engine physics does not work, is not supposed to work, cannot work, and does not work with "bullet like" or "laser like" concepts.

if you have something that zips off the screen in a frame, or is "instant" (like any shooting in any FPS you've ever played) you very simply cast a ray to see what you've hit

(bullets and lasers in video games don't actually fly through the air, they just hit where they are going.)

avatar image
1

Answer by standardcombo · Aug 13, 2013 at 07:44 AM

I realize this is a late response, but:

Decreasing Time.fixedDeltaTime was a solid idea. Try to increase the polygon density on your walls. I've seen the engine work better with more triangles. Go figure.

Looking for a general solution is honorable, but each game has specific needs. An engine like Unity is already as generalized as you will get. Fix the problem at hand. Whatever works!

That said.. for a breakout game with orthogonal walls you should write your own physics and guarantee the results while getting much better CPU usage. Using Unity physics is like killing a mosquito with a cannon. Furthermore, relying on a physics engine for core gameplay is not good practice unless it is a pure physics game (e.g. Bad Piggies?). Spinning your own physics empowers your design.

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.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Do you have to have a rigidbody component for collision detection? 1 Answer

Excluding some physics collisions 3 Answers

Detecting When Intersection Penalty is Being Applied 2 Answers

Tossing an object with the correct force at any distance from another so that it collides with the other 1 Answer

Is it necessary to attach a rigidbody/colliders to child objects? 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