Farseer JetPack LinearImpulse

Topics: Developer Forum, User Forum
Jun 20, 2012 at 9:34 PM

Hi,

 

So i am trying to get a jetpack in my game .Currently i just apply linear imuplse depending on the direction ,something along this lines.

   if (input.KeyboardState.IsKeyDown(Keys.Space))
                    {
                        
                        
                        Body.ApplyLinearImpulse( 10*new Vector2(0,-1));

                        if (input.VirtualState.ThumbSticks.Left.X > 0.5f && input.PreviousVirtualState.ThumbSticks.Left.X > 0.5f)
                        {
                            direction = Direction.Right;

                             
                            Body.ApplyLinearImpulse(7 * new Vector2(1, 0));
                        }
                        else if (input.VirtualState.ThumbSticks.Left.X < -0.5f && input.PreviousVirtualState.ThumbSticks.Left.X < -0.5f)
                        {
                            direction = Direction.Left;
                            Body.ApplyLinearImpulse(7 * new Vector2(-1, 0));
                        }





                    }

 The problem i am running into is ,that if i keep space and the direction pressed i will get a technically infinitively accelerating movement ,which isn't so good i think.So i was wondering if anyone knows a better way of doing this or should i somehow limit the linear velocity for the body?

Thanks