Do not work gravity when apply force horizonally.

Topics: Developer Forum, Project Management Forum, User Forum
Jun 19, 2012 at 5:49 AM
Edited Jun 19, 2012 at 5:51 AM

My games direction of gravity is +Y.

and I make a horizonal scroll game.

 

I applied farseer for terrain and character.

Now I work to move character on terrain and he can jump.

 

but a problem occured.

When I apply force to character +X or -X direction to move character in jump,

he doesn't falling down.

 

If stopping force, normally fall.

 

How can I fix it?

 

Below is some related code of my game.

 

public virtual void Start()
{
      Body body = new Body(World);
      body.BodyType = BodyType.Dynamic;
      body.FixedRotation = true;
      body.Position = Location + new Vector2(Collision.Width / 2, Collision.Height);

      PolygonShape shape = new PolygonShape(0.1f);
      shape.SetAsBox(5, 5);

      PhysicsSimule = new PhysicsFixture(this, body, shape);
}


public virtual void DesireToMove(Vector2 direction)
{
      PhysicsSimule.Fixture.Body.ApplyForce(100000.0f * direction);
}