-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GODOT v 3.3 rc 6 (GD Script & C#) RigidBody2D.LinearVelocity grows after execute RigidBody2D.AddCentralForce ones on it #47137
Comments
This is most likely caused by #38646. In the 2D physics engine, using add_central_force or add_force will add a "constant force" which is applied every frame, whereas apply_central_impulse and apply_impulse add impulse only once. This behavior is inconsistent with the 3D engine, and there's an ongoing debate about which is the correct way, so for now you'll probably just want to use the impulse functions to move things around. |
Hmm to be honest I always thought it is like this:
Thanks for explanation. |
I dig in docs. And from docs it states that using apply_ methods in _process/_physics_process will result in different results where frame rate is variable (not constant). So my questions is what is good way to adjust RigidBody2D with force every frame I don't want force to be "remember" because I will be adding it every frame?
|
Yeah, I got the same idea you did out of the docs, so that confused me as well a while back. Fortunately, there is a pretty simple way to get the expected behavior with the add_ methods, just zero out the applied_force/applied_torque properties at the beginning of _physics_process() like this:
(Got that from the comments in PR #38648, its alternative #42850 is also interesting for context). |
Closing as duplicate of #38646. |
Godot version:
GODOT 3.3 rc 6
OS/device including version:
Linux, Debian 9
Issue description:
Problem with RigidBody2D simulation.
When RigidBody2D is moved by AddCentralForce (even called once) it LinearVelocity doesn't stop.
It (RigidBody2D.LinearVelocity) will increase constantly.
Could be reproduce with GD Script or C#.
Problem doesn't reproduce when RigidBody2D.ApplyCentralImpulse was used.
Steps to reproduce:
Please Run attached project.
Then look into N2D._Ready from ND2.cs.
Look also logs from Godot editor console where you will see values with linear velocity of ball body.
Minimal reproduction project:
TESTPHY__GODOTv32rc5.zip
The text was updated successfully, but these errors were encountered: