I'm creating a game called, Pen Fight, where I need to apply an impulse to a rectangular rigidbody2d.
The weird behaviour that I'm seeing is, apply_impulse(impulse_vector, position) function applies the impulse to the rigidbody even when the position of the impulse is outside the dimensions of the rigidbody. How can I make sure the impulse applies to the place where I want to hit on the rigidbody?
How does apply_impulse() work on RigidBody2D?
- Edited
amityadav even when the position of the impulse is outside the dimensions of the rigidbody
From the documentation for RigidBody2D.apply_impulse():
position is the offset from the body origin in global coordinates.
It looks like the combination of the impulse Vector2 and the position Vector2 determines the point of the body at which the impulse acts.
I'm still not able to understand how I can pass any position Vector2 on the whole screen and it will still hit my rigidbody.