-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Trying to have composite rigidbodies 2D and imprecision issues with linear velocity. #38339
Comments
This part is a duplicate of #288 since single-precision floats are not accurate enough to eliminate this error, they only have about 7 decimal digits of accuracy. When #288 is solved and Godot has the ability to use doubles, you could reasonably expect a vastly smaller error, the value would have to be between |
Thanks for your answer! I thought of the same thing, but wouldn't it be the same issue with doubles? As in I will win precision by doing computations on local coordinates but the velocity will be applied on global coordinates that loose precision. |
@Maveyyl The problems with doubles are vastly smaller. They are half a billion times as accurate. If you are noticing this bug with doubles once Godot supports them, that's a separate bug. I'm not closing this as a duplicate because other parts of this issue may be separate bugs, but I am 100% sure that in order to solve this issue, #288 needs to be solved first. |
As I understand it it's not an engine bug per se but more a discussion about how to mitigate normal precision issues. #288 has now been implemented with the |
Godot version:
3.2.1
OS/device including version:
Windows 10
Issue description:
I've been trying to have composite rigidbodies in 2D, AKA rigidbodies that can enter other bigger rigidbodies and be tied to their parent's accelerations.
Rules are simple: velocities are conserved when entering and leaving. Acceleration of a rigidbodies affect the rigidbodies inside it. Children rigidbodies can freely move but if they're immobile they'll always stick to the same local position (like any non physic node).
How it is achieved: Every _integrate_forces call, I remove the parent's previous velocities and add the new ones. It mostly works with linear velocities, but there's a problem with angular velocities.
The parent's angular velocity has to be translated into children following a circle.
To achieve that I roughly do:
Which visually works, but I am getting tiny errors as soon as the parent starts rotating.
If the parent is at position x 600 and child at 650, it'll compute a local_origin of 50 and a linear_velocity of -0.000229, and I should get the next turn a position of the child of 649,999996.
But next turn it shows me a perfect 650 again, I have an error of -0.000004 that I can't compensate for. Similar errors appear on the y axis as well.
I've tried many things to mitigate the computations errors but they don't seem to change anything. When I compute myself the position it should have using the linear velocity I get the correct position. The angular and linear damps are 0, and I've code that is meant to compensate both when they're not 0 and they work well without errors.
Is it a bug? Is there something I am doing wrong?
Is there a better way to achieve what I've been trying to achieve? I've seen issues suggesting this functionality will be present in godot 4.0 but I've been pulling my hair for at least 15h to try and find a good way to do it. I really want my game to have little ships docked in big ships.
Thanks!
The text was updated successfully, but these errors were encountered: