How to push RigidBody2D straight with impulse?

Godot Version

4.2.2.stable

Question

I have a square that gets moved by an apply_central_impulse() based on the mouse position that acts like an ‘explosion’ to move the square around. My problem is that the impulse doesn’t push the square straight even if lined up perfectly in the center of any side, its always at an angle. How do i go about putting an area in the square that allows the ‘explosion’ to push the square straight?

You need to change the force vector to have either zero x axis, or zero y axis, value. You could check like this

Var point = click_pos - box_pos
Var force_dir = vector2(point.x, 0.0) if abs(point.x) > abs(point.y) else  vector2(0.0, point.y)

...