Continuous Movement of gun bullet

Posted by Siddharth on Game Development See other posts from Game Development or by Siddharth
Published on 2012-05-18T14:10:38Z Indexed on 2012/06/05 10:47 UTC
Read the original article Hit count: 323

Filed under:
|

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.

© Game Development or respective owner

Related posts about box2d

Related posts about andengine