This commit is contained in:
Anuken 2025-05-14 10:24:15 -04:00
parent 2b4c87fb22
commit f1390f3933

View file

@ -35,7 +35,7 @@ import static mindustry.logic.GlobalVars.*;
@Component(base = true)
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Syncc, Shieldc, Displayable, Ranged, Minerc, Builderc, Senseable, Settable{
private static final Vec2 tmp1 = new Vec2(), tmp2 = new Vec2();
static final float warpDst = 30f;
static final float warpDst = 20f;
@Import boolean dead, disarmed;
@Import float x, y, rotation, maxHealth, drag, armor, hitSize, health, shield, ammo, dragMultiplier, armorOverride, speedMultiplier;
@ -647,6 +647,9 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
if(y > top) dy -= (y - top)/warpDst;
velAddNet(dx * Time.delta, dy * Time.delta);
float margin = tilesize * 2f;
x = Mathf.clamp(x, left - margin, right - tilesize + margin);
y = Mathf.clamp(y, bot - margin, top - tilesize + margin);
}
//clamp position if not flying