I have a game where there is no gravity set, and if the ball hits a wall at high enough speed, it bounces off. but if it hits at a low speed it sort of sticks to the wall and rolls along it, and this is not a desired behavior. any way to disable this?
ball sticks to the wall at slow speeds? [solved]
FlashHow do you move the ball ? (Velocity, Impulse, Force ?)
I've had this problem - if you increase the restitution values of the two objects (or at least one of them), the 'sticky' behavior should disappear. Depending on the size and density of the objects, you may have to tweak it a little. It has nothing to do with the gravity or anything though - just restitution.
Xaren wrote:
How do you move the ball ? (Velocity, Impulse, Force ?)
i set the velocity on it using _body.SetLinearVelocity(Vel);
Quote:
I've had this problem - if you increase the restitution values of the two objects (or at least one of them), the 'sticky' behavior should disappear. Depending on the size and density of the objects, you may have to tweak it a little. It has nothing to do with the gravity or anything though - just restitution.
do you remember what kind of values you used? i tried making the ball and walls as low as 0.1 restitution, and as high as 1.1 but i still get the same undesired stickiness. i also tried messing with the density, friction, damping, fixed rotation, and nothing seems to make a difference. i'm sure i'm just doing something dumb.
I had same problem. My solution was that when ball and wall touch i add some small amount of velocity to ball in right direction and they separate =)
You might need to increase the scale of your physics. Very small scale physics will make weaker bounces look bigger, and Box2D has some cutoff where it treats collisions as inelastic. If you use a larger scale, then you won't see that. What I mean is that if your ball is 0.01 m, make it 1.0 m in diameter and increase the size of everything else too.
You could also look into b2Settings.as, there are minimum values for collision. Adjusting these may have performance impacts and or make your simulation unstable, but it also might be exactly what you need.
VengantMjolnir wrote:
You could also look into b2Settings.as, there are minimum values for collision.
BINGO!! 😛
that did it for me, thank you!
i changed: b2_velocityThreshold from 1.0 to 0.1 and this did the trick for me.
here is the old bad one: http://upswf.com/show.php?filename=1272074649250_Golf
and here is the new good one: http://upswf.com/show.php?filename=1272074530843_Golf
Original thread: https://box2d.org/forum/viewtopic.php?t=4720