Here is the link below, how I move bullet to target position using touch point. (Move a body to the touched position using libgdx and box2d)
My problem is how do I stop the bullet body, if bullet body has reach target position.
I already tried the below code, and its working properly.
PIXEL_TO_METER = 1/32.0f
time step = 1/45.0f, velocity iteration = 6, position iteration = 2
float distanceTravelled = targetDirection.dst(bulletPosition);
if(distanceTravelled >= MAX_DISTANCE){
// stop
} else {
// move body
}
but I want to stop the bullet on target position, nor on MAX_DISTANCE. But I have no idea how to do it.