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
3
Question by jinsung486 · Jun 27, 2014 at 07:40 AM · collisionphysicsbounce

How to get a perfect bouncing ball.

In the unity physics system, It may be hard to get a perfect bouncing ball.

Bounciness is 1 and drags,frictions are all 0.

In my thought , it will be a perfect bouncing ball, but it isn't.

It is getting more and more energy.

So, I want to know how to get a perfect bouncing ball in 3D.

In case,

Let me explain my program .

In the cube, there are 300 spheres. they collide with each other and cube.!

Comment
Add comment · Show 4
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 Andres-Fernandez · Jun 27, 2014 at 08:06 AM 1
Share

It would be better if you could explain to us what you mean by "perfect bouncing ball". Is a ball that doesn't lose energy when it bounces perfect? It doesn't sound realistic to me, but maybe that's what you are trying to achieve. So please, explain.

Besides, if you are using physics, you have to think that gravity and other forces have an impact on your ball when bouncing. And you also need to have a look at the bounce combine property, which also plays a role when colliding with other elements.

Again, tell us what you want to achieve and maybe someone can help you.

avatar image jinsung486 · Jun 30, 2014 at 01:53 AM 0
Share

Thank you Andres Fernandez.

I will explain this more detail.

http://en.wikipedia.org/wiki/Elastic_collision

That is, There is no gravity and friction.

And their Bounciness is 1.

avatar image timvanderweijde · Jun 30, 2014 at 06:27 AM 0
Share

The example above is about bouncing between atoms. Those physics are different then 'normal' physics. The physics Engine works with other variables like gravity e.d. So, in other words you have to play with other variables to get your 'perfect' bouncing behavior.

avatar image toromano · Apr 25, 2016 at 12:44 PM 0
Share

This answer might be useful: http://answers.unity3d.com/answers/1086088/view.html

6 Replies

· Add your reply
  • Sort: 
avatar image
11

Answer by chesterhilly · May 08, 2015 at 06:14 PM

I know this sounds sad, but I spent about five mins trying to figure out how close you can get to perfect bounces with the physic material.

  1. Create a physic material

  2. Set the bounce combine to maximum

  3. Change bouciness to 0.9699999 exact

I don't know if its much different to that but I put a background behind it and I saw it reach the same point.

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 AlexTheHollow · Jan 01, 2016 at 10:11 PM 0
Share

A lot of months late but I think this was the best answer. It worked amazingly.

avatar image AbhimanyuAryan · Apr 25, 2016 at 09:01 AM 0
Share

here what I got perfect bounce on "0.9805824"

avatar image
4

Answer by dakmau · Aug 29, 2016 at 09:30 AM

SOLVED

I had the same issue and resolved it without any code. My bouncing object was gaining kinetic energy with each bounce.

The issue was that the collision detection property was set to discrete.

Go into the rigidbody component and set the collision detection to continuous. That's it.

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 phillyharper · Oct 13, 2016 at 10:57 AM 0
Share

This worked for me. I had the exact same problem and this solved it. I had a paddle, and a ball with gravity 1, and bounciness 1. When it hit my collider on the paddle, it would bounce, but get extra energy each time.

Changed collision detection on Rigidbody of ball to continuous, and it fixed it. I have no idea why it works.

Documentation says:

Collision Detection How collisions with other objects are detected. Discrete A collision is registered only if the object’s collider is in contact with another during a physics update. Continuous A collision is registered if the object’s collider appears to have contacted another between updates.

Don't see why that made a difference?

avatar image Huacanacha phillyharper · Oct 14, 2016 at 07:23 PM 0
Share

At a guess: continuous collision may resolve the collision at the effective time of impact, whilst discrete collision resolves at the frame time where objects are already overlapping. The temporal inaccuracy of the discrete collision calculation could then potentially add energy to the system.

avatar image
3

Answer by Huacanacha · Jun 30, 2014 at 04:25 AM

I'd be happy to be proved wrong but as far as I know Unity and/or nVidia don't publish the equations uses for PhysX calculations, nor make anything like physic materials user extendable, so it is basically impossible to construct accurate physics systems based on precisely researched values. Unfortunately this seems to extend to edge cases like elastic collisions (zero energy loss). I've seen the same thing where full bounciness with zero friction and drag results in energy being added, and balls gaining rotational energy when they should be slowing down due to friction. I'm not sure if this is a floating point math issue, a bug, or a known limitation.

Fortunately elastic collisions with fixed surfaces are easy enough to calculate yourself. Forget Physic Materials and do something like this:

  • Don't use Unity collision handling (not sure if this is possible when using OnCollisionEnter)

  • Use OnCollisionEnter or OnTriggerEnter to be alerted when a collision occurs

  • OnCollisionEnter: Calculate the average of the normals of the collision... OnTriggerEnter: use a Raycast to find the collision surface and get the normal

  • Use Vector3.Reflect to reflect velocity: "rigidbody.velocity = Vector3.Reflect(rigidbody.velocity, normal);"

For my game Stryker: First Person Football I had to use a hybrid custom + PhysX physics system to work around the limitations of the builtin Unity Physics, including modifying the dynamic friction based on the speed of the ball. It's far from perfect but the result is fairly realistic.

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 Benproductions1 · Jun 30, 2014 at 05:24 AM 1
Share

You'd get a +1 from me, if you weren't advertising.

avatar image Huacanacha · Jun 30, 2014 at 05:43 AM 0
Share

You're right, I'll remove the link but leave the game name as it's potentially relevant to the discussion.

avatar image Lord_amateur · Sep 26, 2018 at 01:53 PM 0
Share

can you please give an example piece of code showing how did you do that? I am not getting the correct values of normal when I tried to do this.

avatar image
2

Answer by thejaswip · Mar 22, 2016 at 01:48 PM

void OnCollisionEnter(Collision collision) {

     rigidbody.velocity = new Vector3 (collision.relativeVelocity.x, collision.relativeVelocity.y);

 }
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
0

Answer by Muffio · Jun 25, 2018 at 11:22 AM

I found that it only bounces perfectly (reaches the exact same height each time it bounces) if the "Linear Drag" and "Angular Drag" properties are set to 0 and the "Collision Detection" property is set to "Discrete" on the Rigidbody (I am using a 2D Rigidbody). The Physics material must have exactly 1 "Bounciness" and 0 "Friction".

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

36 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

Related Questions

how the ball bounces of equal in angles? 1 Answer

Ball bounce angle 1 Answer

Object with rigidbody bounces after hit. 0 Answers

Enemy bouncing physics 0 Answers

Unity2D Collision is bugged 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