Physics Bug

Hi,

I don’t know why but some collisions are randomly slowing down/speeding up objects.

Physics set to 0 gravity
Ball object set to 1 bounce, 0 friction, 1 density, radius 16
Environment objects no bounce set and 0 friction, basically they are square blocks.

The environment is a walled of box with random static blocks around.

In this scenario, the ball is supposed to bounce off objects without stopping and change in velocity.

I let the simulation run for a few minutes and depending on what objects the ball collides with(which is determined by which angle the ball is moved initially), it either builds up a lot of speed or slows down to a very low speed.

Perhaps it may be due to the angle of collision, perhaps it may be due to inaccurate hitboxes? [import]uid: 75783 topic_id: 12987 reply_id: 312987[/import]

I vaguely recall having the same problem once, and if I remember correctly I just had to set the ball to a fixed rotation like this:

ball.isFixedRotation = true;

/Ingemar
[import]uid: 70847 topic_id: 12987 reply_id: 47643[/import]

Hmm it was already set to fixed rotation. [import]uid: 75783 topic_id: 12987 reply_id: 47645[/import]

Have you double-checked all *all* walls and objects have friction=0.0 and bounce=1.0?
Is so, I’m sorry to say I’m stumped… [import]uid: 70847 topic_id: 12987 reply_id: 47653[/import]

Are the blocks straight or rotated? Can you post code to showcase the problem? [import]uid: 27965 topic_id: 12987 reply_id: 47696[/import]

Due to tiny rounding errors in the Box2D physics engine, over many collisions the errors will build up, and either speed up or slow down the object. This is in the documentation for the physics engine - it gives an example of a bouncing ball with gravity, and says there’s no way to have it keep bouncing at the same height.

There’s actually no way to replicate a “perfect” bounce = 1 over many collisions.

You’ll need some external “help” for that - for example manually checking your velocity every once in a while and then fixing it if it’s off. Although be careful, I think I’ve seen some posts about problems with manually setting your velocity when physics is running. Maybe a series of small “impulses” to slow it down if necessary…

Good luck! [import]uid: 49372 topic_id: 12987 reply_id: 47699[/import]