How to make a ball bounce always to the same height?
Hello. My ball has a bounciness of one. Still every time it hits the ground it bounces a little higher than it was before. I want it to return to the same height every time it bounces and I've tried to use different things for the ball to bounce off from but the same problem occurs every time. All fricitions, gravity etc. supposely have the default values as I've just downloaded Unity and started a new project.
WHAT TO DO?
So, are you saying that you want the ball to bounce over and over again, and each time it bounces, it bounces up to the same height?
Or, are you saying that the each time the ball first bounces, you want that first bounce to bring it up to the same height always?
Have you tried changing the default values...removing friction what not?
I want the ball to bounce over and over again to the same height. $$anonymous$$y ground (a box collider) doesn't have any physic material on it and I've tried to change the ball's frictions but only drag and bounciness seem to affect the bouncing height.
And I forgot to mention that my ball's drag is zero. So when the bounciness is set to 1, isn't the ball supposed to always return to the same height every time it bounces?
You could remove the bounciness in total and just AddForce via script on collision with the ground.
I have the same problem. I just want to let the ball bounce, without writing code for it, why does it jumps higher each time, given that the bounciness is 1, it should be the same height...
Hi, i need help with same problem, did you find out how to do it`?
Answer by derianmeyer · Nov 27, 2016 at 03:02 PM
After digging around the forums I found the answer posted by jeffreyschoch (link at the bottom).
On the ball, set your Collision Detection to "Continuous" (it defaults to "Discrete"). I left Interpolate at "None". I tested and it works great!
@derianmeyer This appears to be the correct answer, and not the answer using the hack of "0.9805824" (which has a higher vote).
I googled, to find this answer, when following the udemy unity course (It's not that good, so I'm not sure I'd recommend it) - In his video, his ball was still set to Discrete, but always returns to the same point - but for me, it wasn't - So it's weird that in the video, his is set to Discrete and returns to the same point, but for me I had to set it to Continuous (maybe it has something to do with different versions of unity - I'm using the latest version of 4.6, as the video recommends, but maybe he's using an earlier or later version) - I don't know.
I think we took the same course. His collision detection is still set to Discrete, but it does NOT return to the same point! The video is wrong.
And yes, this is the correct answer.
I've set the collision detection to "continuous dynamic". Interpolate is still None. Physics $$anonymous$$aterial's Bounciness is set to 1, friction (dynamic and static) is set to 0. Friction Combine and Bounce Combine is set to $$anonymous$$aximum.
The Ground has a Box Collider which doesn't have a $$anonymous$$aterial added. Unfortunately my sphere get's higher than it was before. Any ideas? Using Unity 2017.3.0f3.
Thanks!
In 2019.3 setting the collision detection to (discrete / continuous / continuous dynamic / continuous speculative) + interpolate (none / interpolate) doesn't help. Had to stick to the other solution of setting the bounciness slightly below 1.
Answer by leonalchemist · Apr 21, 2015 at 07:19 PM
After some testing my physics object has bounce combine set to maximum, friction to minimum and bounciness to 0.9805824, its not perfect but this is pretty darn close to a perfect bounce, even if left an object to bounce for an hour it will pretty much and no visible difference even zoomed in.
Answer by reevthechameleon · Mar 12 at 03:21 AM
I have found that, for whatever reason, attaching this script to the ball cause it to bounce back to the same height, even when "Collision Detection" is set to "Discrete":
using UnityEngine;
public class Bounce : MonoBehaviour{
private Vector3 vPrevPos;
void FixedUpdate(){
vPrevPos = transform.position;
}
void OnCollisionEnter(Collision c){
transform.position = vPrevPos;
}
}
The condition I use is to drop the ball onto the plane from 5 units above it and let the ball bounce for 15 minutes, then confirm that the maximum height of the ball is still 5 units. I use Physics Material with friction of 0 and bounciness of 1 on both the ball and the plane, and make sure that drag on Rigidbody Component of the ball is 0. I use Unity version 2019.4.16f and 2020.3.30f.
Your answer
Follow this Question
Related Questions
How to make bounce ball always the same height 1 Answer
How do I make a ball have force where it bounces and adds force in the direction it is going at? 0 Answers
How to move an object without impacting it's natural gravitational behavior 1 Answer
I can't jump the ball like I want 0 Answers
How far ball (cirlce object) roll? 1 Answer