godotengine / godot

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

[Bullet] Area zero gravity with Bullet #40127

Open eberan opened 4 years ago

eberan commented 4 years ago

Godot version: Godot 3.2.2 Official, Standard 64bit (Windows)

OS/device including version: Windows 10 GPU: Nvidia 1060m Backend: GLES2

Issue description: Short: RigidBody in Area with zero gravity override still has some initial (internal) force applied, while using Bullet but not Godot physics. Expected results are zero forces applied and RigidBody remains still. Potentially related to Issue #32776 or #35378.

Steps to reproduce:

Minimal reproduction project: bzg.zip

AndreaCatania commented 4 years ago

A solution to fully fix this, is to perform a collision check when the body enters the world. I'm not a big fan on this idea, TBH, because the gain is little and the cost is huge.

Scripting side this issue can be avoided easily, so I want to think a bit more on this, to see if it worth or not fixing it. In the meanwhile I'm open to suggestion.

eberan commented 4 years ago

Thanks for the comments @AndreaCatania. Any chance you could give a few lines of example script/code that would manually add an object to an area? I'm just not seeing how to, yet. Regarding the changes necessary to accomplish this by default, do you have any idea why it behaves differently with Godot physics in this regard?

AndreaCatania commented 4 years ago

The gravity is applied only the first frame so:

So, you should do something that make sure to freeze the body the first frame

mrjustaguy commented 4 years ago

Can Confirm that it is related to #32776 and the problem seems to be that it just doesn't update the needed area settings in stuff affected by the area, whereas Godot Physics does it just fine.

The issue I started as stated above was in regards to such issues with gravity. One thing i did notice in a project i've started working on just a few days ago is that when Gravity Point is on, everything works as expected. rotating the area (to change which way is supposed to attract the rigid body) by using a position3d as a gimbal, adding an area as a child and moving it by alot (-100 y axis) and adding a collision shape to the area and moving it to the exact opposite of the area to get it to an effective 0 y axis value in relation to the position3d gimbal used, when Gravity point is on, the rigid body goes to the area and correctly changes it's gravity according to the gimbal rotation (meaning the body is going to the position of the area node as it should)

Try doing something like that without Gravity point on in bullet and you will fail to change the axis of the gravity for any objects that are in at the time of the change in the gravity vector, however Godot phys will do it the way it should work in bullet too.