- Home /
Bouncing when dealing with fast moving objects
I am making a game that involves bouncing a ball off of static objects. Sometimes the ball moves to fast and passes through the other objects ignoring their colliders.
I changed the balls collision detection mode to continuous to try to solve the problem. While this did solve the problem of the ball ignoring the colliders, the collision is still problematic. I have a physics material that allows the ball to bounce off of the other objects. However, which the collision dection mode set to continuous, the bounce off the objects would be delayed or non existent.
Any idea on a work around, that allow fast objects to collide with static objects and smoothly bounce off smoothly?
Answer by ScroodgeM · Jul 19, 2012 at 06:47 PM
method 1: make a static colliders thick enough so it can't be intersect in one fixed-update cycle
method 2: make a fixed-update cycle lower (edit - project settings - time)
method 3: make a rigidbody kinematic and apply physic manually. ball usually have very easy physic model so it will not be a trouble.
I have thought about the first two, but the 3rd method is new to me. Would you $$anonymous$$d describing what it would entail as it seems promising?
i worked in one project where player controls a cannon and fires with cannonballs. cannonballs has a great speed especially at start of way, and it was an issue to calc physic manually cause theese balls often turned out to be below terrain. speed was too high to fix it using first two methods. so i used a third one.
first to control kinematic rigidbodies you must apply speed manually. current speed must be stored in property
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.$$anonymous$$ovePosition.html
second, simply add gravity - every fixed update add an offset to speed (speed += new Vector3(0f, -9.8f, 0f) * Time.fixedTimeStamp)
and the last one - just detect a collisions with other objects and get a contact point, then apply reflected speed. also apply a multiplier to speed to imitate bouncing power.
http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Reflect.html
also can be an issue where ball collides just intersected surface - then you just need to move ball by surface normal from 'below' to 'above' surface
should work little better then built-in physic calculating.
Hey thanks for the help. That option didn't really cross my $$anonymous$$d. Essentially, there would be some high school physics involved. I'm not sure if it would be the simplest solution currently after overlooking my setup. On another note, I stumbled across http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings which seems to fit better in my situation.
Yet, thanks for another workaround which I'm sure I will use in the future.
Answer by Paulo-Henrique025 · Jul 20, 2012 at 04:40 AM
Take in mind the scale of your objects, if you are working with a large ball(~15x the normal) you are for sure applying a very strong gravity so it can move very fast, and there is a problem: Large objects aways seems to move slower because you are looking at them from far away, them you apply more and more force to make it faster and break the physics because your "step" is so big that is ignoring colliders.
Make a X:1 Y:1 Z:1 scale ball and apply your physics just to test it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613074403im_/https://answers.unity.com/themes/thub/images/avi.jpg)