Fixed unit movement overshoot
This commit is contained in:
@@ -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