0

Ok so I currently have a very simple steering behaviour on my game. One object chases another. The problem is that the chasing object ends up orbiting the other object indefinitely. Is there any way of solving this in box2d? Right now all I've got is linear damping, which slows it down when it gets close which kind of helps but I really want to kill the momentum so it can immediately change direction kind of like on Step 7 of this tutorial: http://code.tutsplus.com/tutorials/hit-the-target-with-a-deadly-homing-missile--active-8933 ... except in Box2D.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217

2 Answers2

0

Maybe something like this:

if(//on target area){
setLinearVelocity(0f,0f);
setAngularVelocity(0f);
steeringBehavior = null;
}

P.S. Probably, you may use Arrive behavior instead (it has a drag to stop on target)

Andrei Yusupau
  • 587
  • 1
  • 11
  • 30
0

I used the setLinearDamping() method in the end which slowed the chaser as it got closer.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95