Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was using box2d for the movement of the body. When I apply gravity (0,0) the bullet continuously move but when I change gravity to the earth the behavior was changed. I also try to apply continuous force to the bullet body but the behavior was not so good. So please provide any suggestion to continuously move bullet body in earth gravity.

currentVelocity = bulletBody.getLinearVelocity();
if (currentVelocity.len() < speed|| currentVelocity.len() > speed + 0.25f) {
    velocityChange = Math.abs(speed - currentVelocity.len());
    currentVelocity.set(currentVelocity.x* velocityChange, currentVelocity.y*velocityChange);

I apply above code for the continuous velocity of the body. And also I did not able to find any setGravityScale method in the library.

share|improve this question

Bullets are subject to gravity as well, they just usually move so fast that it doesn't matter. Are you trying to make something like a rocket that moves quite slowly but steadily across the screen?

You could go around the problem by continuously applying force equal and opposite to the gravity.

share|improve this answer
Yes I was making somewhat like rocket in my game. I apply continuous force equal and opposite gravity but that does not work for me and direction of the bullet was change. – Siddharth May 19 '12 at 9:44
After soom googleing it seems setting to body type to kinematic disables gravity for that body: body.type = b2_kinematicBody; Another option is setting the gravity scale for that body to zero: body->SetGravityScale( 0 ) – Roy T. May 19 '12 at 11:28
up vote 0 down vote accepted

Update your andengine library for the gravity of the body.By implementing body.setGravityScale(0) method in the library the body does not feel any gravity from the physics world.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.