Fixed unit movement overshoot
This commit is contained in:
@@ -127,7 +127,7 @@ public class CommandAI extends AIController{
|
||||
attackTarget != null && unit.within(attackTarget, engageRange) ? engageRange :
|
||||
unit.isGrounded() ? 0f :
|
||||
attackTarget != null ? engageRange :
|
||||
0f, unit.isFlying() ? 40f : 100f, false, null);
|
||||
0f, unit.isFlying() ? 40f : 100f, false, null, true);
|
||||
}
|
||||
|
||||
//calculateFlock().limit(unit.speed() * flockMult)
|
||||
|
||||
@@ -278,6 +278,10 @@ public class AIController implements UnitController{
|
||||
}
|
||||
|
||||
public void moveTo(Position target, float circleLength, float smooth, boolean keepDistance, @Nullable Vec2 offset){
|
||||
moveTo(target, circleLength, smooth, keepDistance, offset, false);
|
||||
}
|
||||
|
||||
public void moveTo(Position target, float circleLength, float smooth, boolean keepDistance, @Nullable Vec2 offset, boolean arrive){
|
||||
if(target == null) return;
|
||||
|
||||
vec.set(target).sub(unit);
|
||||
@@ -286,6 +290,11 @@ public class AIController implements UnitController{
|
||||
|
||||
vec.setLength(unit.speed() * length);
|
||||
|
||||
if(arrive){
|
||||
Tmp.v3.set(-unit.vel.x / unit.type.accel * 2f, -unit.vel.y / unit.type.accel * 2f).add((target.getX() - unit.x), (target.getY() - unit.y));
|
||||
vec.add(Tmp.v3).limit(unit.speed() * length);
|
||||
}
|
||||
|
||||
if(length < -0.5f){
|
||||
if(keepDistance){
|
||||
vec.rotate(180f);
|
||||
|
||||
Reference in New Issue
Block a user