# Continuous Movement of gun bullet

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);
bulletBody.applyLinearImpulse(currentVelocity,bulletBody.getWorldCenter());
}
``````

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.

-

## 2 Answers

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.

-
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

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.

-