Fix explosion impulses to apply against the rigidbody's center of mass

This commit is contained in:
Squinty 2024-04-19 14:27:04 +00:00
parent 53965ae605
commit a583dc59a1
2 changed files with 4 additions and 1 deletions

View file

@ -20,7 +20,8 @@ class_name ExplosiveDamageComponent extends Area3D
func _physics_process(_delta : float) -> void:
for body in get_overlapping_bodies():
if body is RigidBody3D:
var direction : Vector3 = (body.global_position - global_position).normalized()
var center_of_mass_global_position : Vector3 = body.center_of_mass + body.global_position
var direction : Vector3 = ( center_of_mass_global_position - global_position).normalized()
body.apply_central_impulse(direction * impulse_force)
for area in get_overlapping_areas():