Fix RigidDynamicBody gaining momentum with bounce
Bounce calculation now uses the previous frame's velocity, so it's consistent with the actual motion of the bodies involved and not the yet-to-be-applied forces. When bounce is 1, using the current velocity was causing the new forces (including gravity) to be taken into account, which lead to the bounce velocity to be higher than the falling velocity at the moment of impact, adding more and more energy over time.
This commit is contained in:
parent
b3ec5a16ea
commit
7032cf0637
6 changed files with 24 additions and 20 deletions
|
|
@ -549,6 +549,9 @@ void GodotBody2D::integrate_forces(real_t p_step) {
|
|||
|
||||
gravity *= gravity_scale;
|
||||
|
||||
prev_linear_velocity = linear_velocity;
|
||||
prev_angular_velocity = angular_velocity;
|
||||
|
||||
Vector2 motion;
|
||||
bool do_motion = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue