godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.2k stars 21.21k forks source link

Engine applies wrong gravity to rigid bodies. #92212

Open RonYanDaik opened 6 months ago

RonYanDaik commented 6 months ago

Tested versions

4.1 - 4.2.Stable - 4.3.Preview.6

System information

Godot v4.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 31.0.15.5244) - Intel(R) Core(TM) i9-10900KF CPU @ 3.70GHz (20 Threads)

Issue description

It seems like physics engine applies wrong gravity to rigid bodies. (I've tried both Godot physics and Jold3D addon) I'm not an expert at physics but I've never seen physics behave like that in other engines. Since we don't have any air friction applied to bodies, they should follow calculated predicted trajectory matching it.

Bellow I've attached an example project. First GIF is where bodies are solved by the engine. And the don't reach target (strange thing happened while i was creating this bug report, the bodies started to fly only half the way, while just a minute before they been reaching 90% of distance to target. I could not figure why this happened, and cant revert both the projects (mine and minimal-example) to previous state. But neither less the behavior is persistent between projects and engine versions 4.1-4.3.) Second GIF is where I'm Using custom integrator forces and just add gravity to velocity. (Now rigid bodies actually reaches target) gravity_bug_2 Custom Integrator version: gravity_bug_3

This is example from GDQuest. I've changed projectiles to rigid bodies 3d. And we can see that now they are falling slightly off, not reaching the target. gravity_bug_1

Steps to reproduce

Calculate velocity for projectile needed to reach target and apply it to RigidBody3D.

Minimal reproduction project (MRP)

Gravity_Bug_Report.zip

AThousandShips commented 6 months ago

Since we don't have any air friction applied to bodies

Have you turned down physics/3d/default_linear_damp, or set the linear damp mode to replace? I suspect that is ignored with custom integration

RonYanDaik commented 6 months ago

Have you turned down

Oh, no.... No I have not... I've been trying to understand what wrong entire day. After turning it off, it actually started to behave normally in some cases. Probably other cases are just my mistake then.

AThousandShips commented 6 months ago

See the documentation for more details

RonYanDaik commented 6 months ago

strange thing happened while i was creating this bug report, the bodies started to fly only half the way

But wait, also i think why this happened. Having _integrate_forces in the class but custom_integrator option off still calls _integrate_forces function.

AThousandShips commented 6 months ago

Please search for a duplicate issue for that and open a dedicated issue report for that