ApplyLinearImpulse To A Circle

Topics: User Forum
Feb 11, 2011 at 9:23 AM

This doesnt seem to work just right.  Im simply trying to launch a ball in the direction I touch on the phone.  I want the angle and magnitude to be relative to the position I touch.  Now, this seems to partially work when I touch in some areas, like to the left and up, or left and down.  But to the right things go weird and too far out away from the ball and things go weird.  Any help would be great.  I'm using the latest physics helper.

For the most part the ball only needs impulse applied to it once and thats it...

_boundryHelper = new BoundaryHelperBox2d(physicsCanvas);
_ball = _physicsController.PhysicsObjects["ballOutter"];

var touchPos = new Vector2((float)e.ManipulationOrigin.X, (float)e.ManipulationOrigin.Y);
var touchWorld = _boundryHelper.ScreenToWorld(touchPos);
_ball.BodyObject.ApplyLinearImpulse(touchWorld, _ball.BodyObject.Position);

Feb 11, 2011 at 6:36 PM

My bad, this actually works.  My camera target was throwing things off visually and made it appear not to work, once I set the camera target properly all was good.