Improved avoidance

This commit is contained in:
Anuken
2019-03-30 12:33:01 -04:00
parent eb3d5b62f5
commit 83bde8a781
3 changed files with 6 additions and 6 deletions

View File

@ -65,7 +65,7 @@ public class Pathfinder{
Tile other = world.tile(dx, dy);
if(other == null) continue;
if(values[dx][dy] < value && (target == null || values[dx][dy] < tl) &&
if(values[dx][dy] < value && (target == null || values[dx][dy]< tl) &&
!other.solid() &&
!(point.x != 0 && point.y != 0 && (world.solid(tile.x + point.x, tile.y) || world.solid(tile.x, tile.y + point.y)))){ //diagonal corner trap
target = other;

View File

@ -215,7 +215,7 @@ public abstract class GroundUnit extends BaseUnit{
velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta()));
if(Units.invalidateTarget(target, this)){
rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed);
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
}
}
@ -240,6 +240,6 @@ public abstract class GroundUnit extends BaseUnit{
float angle = angleTo(targetTile);
velocity.add(vec.trns(angleTo(targetTile), type.speed*Time.delta()));
rotation = Mathf.slerpDelta(rotation, angle, type.rotatespeed);
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
}
}

View File

@ -245,15 +245,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
for(int cy = -rad; cy <= rad; cy++){
Tile tile = world.tileWorld(x + cx*tilesize, y + cy*tilesize);
if(tile == null) continue;
float scl = (rad - Mathf.dst(tile.worldx(), tile.worldy(), x, y)/(8f * 1.2f * Mathf.sqrt2)) * 0.08f;
float scl = (rad - Mathf.dst(tile.worldx(), tile.worldy(), x, y)/(8f * 1.2f * Mathf.sqrt2)) * 0.1f;
moveVector.add(Mathf.sign(x - tile.worldx()) * scaling * tile.weight * scl, Mathf.sign(y - tile.worldy()) * scaling * tile.weight * scl);
}
}
//moveVector.limit(0.2f);
moveVector.limit(0.2f);
move(moveVector.x, moveVector.y);
applyImpulse(moveVector.x, moveVector.y);
Tile tile = world.tileWorld(x, y);