mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-13 09:17:28 +07:00
Improved avoidance
This commit is contained in:
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user