Impact sounds on ragdoll

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

Is there any way of adding sound effects when a PhysicalBone3D of a ragdoll hits the ground or any other static body? Rigidbodies have the body_entered signal, but physical bones do not.

I think the easiest way is to add an Area3D that takes care of that but if you still want to use a PhysicalBone3D then, because it’s a PhysicsBody3D you can set the maximum amount of contacts to report to something bigger than 0 directly with PhysicsServer3D.body_set_max_contacts_reported() and use PhysicalBone3D._integrate_forces() to know when a contact has happened.

Example:

extends PhysicalBone3D


func _ready() -> void:
	PhysicsServer3D.body_set_max_contacts_reported(get_rid(), 1)


func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
	if state.get_contact_count() > 0:
		print("contact!")
1 Like

I read a discussion on github that mentioned Area3D but I did not consider using it this way, so thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.