haxball / haxball-issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bCoeff of 1 does not give a perfectly elastic bounce

RicardoPinto26 opened this issue · comments

Hi,

I was looking into calculating the force of impact of two players, and one thing led to another, and I ended up making a map to test what the bCoeff and damping did.

In the meanwhile, I have learned that bCoeff basically means the coefficient of restitution, and that damping is just a "friction" applied at every tick. #394

In the map I made, I set the player's y gravity to 1, their bCoeff to 1, damping to 1, and the plane's bCoeff to 1. However, I noticed that the resulting speed from the bouncing was greater than the initial speed, contrary to the coefficient of restitution set.

I found that the speed increased 2 extra units of gravity at the bounce, I'm guessing in the tick before the collision, and the tick after the collision.

Has this been reported previously? Is there a fix for this?

This isn't a exactly a bug, it's caused by the way collisions are resolved in the game.
The game detects collisions when two objects are overlapping each other, after a collision is found the objects are first separated (their positions moved so that they are no longer overlapping), only after separating them the velocities are reflected over the collision normal using the bCoef to scale the relative speed.
The overlap separation in the presence of gravity ends up adding potential energy to the system which is what you are detecting.

There's no fix for it.

Thanks for the reply.

I actually have another question. When two balls collide, both have a bCoeff (which can be equal or not). What do you use as the resulting bCoeff? Is it the average of the two, or do you simply multiply one by the other?

Sorry if this is a simple physics question, I haven't actually studied any of this xd

They multiply, if both are 0.5 it's the same as if one had 1 and the other 0.25.