godotengine / godot

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

[Bullet] _integrate_forces(state) not reporting contacts, normals #58409

Open valknor opened 2 years ago

valknor commented 2 years ago

Godot version

3.4.2

System information

Debian 11 (Linux)

Issue description

Hello,

When using the Bullet Physics Engine (currently the default for Godot 3.4), sometimes the _integrate_forces method fails to return a value other than 0 for get_contact_count or get_contact_local_normal, for a RigidBody. This appears to be similar to issue 43806.

Steps to reproduce

Putting the following in a RigidBody's script displays the problem for me:

func _integrate_forces(state):
    print(state.get_contact_count())
    print(state.get_contact_local_normal(0))

I am including a project that should reproduce this problem below. Simply Run full speed toward the green ramp in the middle, and pay attention to the printout in the output window. The script in question is Lee.gd located in the assets folder. You should notice that the other two ramps work fine, as do most objects in the game. This problem seems to be frequently mitigated by using a trimesh collision sibling. However these do not always compensate for more complex meshes, such as the insides of cylinders.

Minimal reproduction project

gammaball.zip

D3ZAX commented 2 years ago

You need set "Contacts Reported" property of RigidBody node greater than 0 to get contact in _integrate_forces. I found you just leave it to 0.

Actually, I don't think leave default value to 0 is good idea, for it just looks like a bug.