This project has moved and is read-only. For the latest updates, please go here.

Odd problem with applyLinearImpulse

Topics: User Forum
Feb 3, 2012 at 5:32 AM

I am trying to make bullet like objects which travel quick, but their speed seems to be capped. To test this I made the character body applyLinearForce(new Vector2(0,-10). That effectively makes it jump(if gravity was on, which it's not, so it just goes flying off screen).

Now for the bullets(which are generated on a mouse click) I made them use the same sprite and the same body constructor as the character. Upon creation of a bullet I applyLinearForce(new Vector2(0,-10) and it does not move nearly as fast as the character.

I'd really appreciate any help. Relevant code is below


_projectileBody = BodyFactory.CreateCircle(world,96f / (2f * MeterInPixels, 1f, _projectilePosition);                                                     _projectileBody.BodyType = BodyType.Dynamic;

//circlebody is the character

_circleBody = BodyFactory.CreateCircle(_world, 96f / (2f * MeterInPixels), 1f, circlePosition);
_circleBody.BodyType = BodyType.Dynamic;

if (state.IsKeyDown(Keys.Space) && _oldKeyState.IsKeyUp(Keys.Space))
                    _circleBody.ApplyLinearImpulse(new Vector2(0, -10));

_projectileBody.ApplyLinearImpulse(new Vector2(0, -10));