StaticBody2D.apply_impulse() -- setting position to point of impact

Godot Version

4.5.1.stable

Question

An Area2D “rocket” comes into contact with a StaticBody2D. I want the impact to slightly push back the body.

in the _on_body_entered(body: Node2D) function, I currently have this:

func _on_body_entered(body: Node2D) -> void:
     if body is RigidBody2D:
          body.apply_impulse(
               self.global_position.direction_to(body.global_position) * 200,
               Vector2.ZERO)

the “position” parameter of apply_impulse()is currently Vector2.ZERO, or the body’s center.

I want to offset position to be where the Area2D came into contact with the RigidBody2D.

The "position” parameter states “position is the offset from the body origin in global coordinates”.

How do I translate “the global position where the Area2D came into contact with the RigidBody2D” into “position offset from body origin in global coordinates”

Thanks in advance.

I’m assuming that the code you posted is on the area? An area won’t have a single point where it contacts the rigidbody. It might be better to use a raycast if you want a single point.