Impulse a Nape body in direction to a specific position

1.7k views Asked by At

I have a sleep body I want to apply an impulse in direction to a specific x/y position, let's say x:200, y:300.

But when this impulse is applied the body moves in direction to the x/y but not to the exactly position, it has a difference range around 30-50 on both x/y. Gravity is 0,0.

var impulse:Vec2 = Vec2.weak(200, 300);
impulse.length = 1000;
napeBody.applyImpulse(impulse); 
1

There are 1 answers

0
Chris On

Done it. In case someone need it, you just need to set x/y on the impulse according to your body position:

var dx:Number = _destX - napeBody.position.x;
var dy:Number = _destY - napeBody.position.y;

var impulse:Vec2 = Vec2.weak(dx, dy);
impulse.length = 1000;
napeBody.applyImpulse(impulse);