From dd7f91b8c2627183a10aafb414d92f040620a100 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 2 Oct 2018 20:45:28 -0400 Subject: [PATCH] Fixed many various physics bugs --- build.gradle | 2 +- core/src/io/anuke/mindustry/content/Mechs.java | 8 -------- core/src/io/anuke/mindustry/content/UnitTypes.java | 3 +++ .../mindustry/content/blocks/TurretBlocks.java | 4 ++-- core/src/io/anuke/mindustry/entities/Unit.java | 4 ++-- .../io/anuke/mindustry/entities/bullet/Bullet.java | 4 ++-- .../anuke/mindustry/entities/units/GroundUnit.java | 14 ++++++-------- core/src/io/anuke/mindustry/type/Mech.java | 2 +- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index c030f9f3af..27bf254542 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' roboVMVersion = '2.3.0' - uCoreVersion = 'ee0de709b7ab7bc993db42436a378ceee88c6460' + uCoreVersion = '8b72f5b0fadc4a2133337d9db4651ac4794581d9' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index b01c844dad..11145fcd73 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -46,7 +46,6 @@ public class Mechs implements ContentList{ speed = 0.5f; boostSpeed = 0.85f; weapon = Weapons.blaster; - maxSpeed = 4f; trailColorTo = Color.valueOf("ffd37f"); armor = 20f; } @@ -89,7 +88,6 @@ public class Mechs implements ContentList{ weaponOffsetY = -1; weapon = Weapons.shockgun; trailColorTo = Color.valueOf("d3ddff"); - maxSpeed = 5f; } @Override @@ -122,7 +120,6 @@ public class Mechs implements ContentList{ drag = 0.35f; boostSpeed = 0.8f; weapon = Weapons.healBlaster; - maxSpeed = 5f; armor = 15f; trailColorTo = Palette.heal; } @@ -166,7 +163,6 @@ public class Mechs implements ContentList{ weaponOffsetY = 0; weapon = Weapons.swarmer; trailColorTo = Color.valueOf("feb380"); - maxSpeed = 3.5f; armor = 45f; } @@ -218,7 +214,6 @@ public class Mechs implements ContentList{ drillPower = 1; mineSpeed = 0.9f; speed = 0.4f; - maxSpeed = 10f; drag = 0.1f; armor = 10f; weapon = Weapons.blasterSmall; @@ -235,7 +230,6 @@ public class Mechs implements ContentList{ { drillPower = -1; speed = 0.11f; - maxSpeed = 10f; drag = 0.01f; mass = 2f; armor = 5f; @@ -290,7 +284,6 @@ public class Mechs implements ContentList{ { drillPower = 2; speed = 0.12f; - maxSpeed = 10f; drag = 0.035f; mass = 2.5f; turnCursor = false; @@ -313,7 +306,6 @@ public class Mechs implements ContentList{ drillPower = 4; mineSpeed = 1.3f; speed = 0.32f; - maxSpeed = 10f; drag = 0.06f; mass = 3f; armor = 30f; diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index a2b8125d71..52bc0ebc84 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -24,6 +24,8 @@ public class UnitTypes implements ContentList{ maxVelocity = 1.7f; range = 40f; health = 45; + hitsize = 4f; + mass = 0.1f; weapon = Weapons.droneBlaster; trailColor = Color.valueOf("ffd37f"); } @@ -84,6 +86,7 @@ public class UnitTypes implements ContentList{ speed = 0.3f; maxVelocity = 1.9f; drag = 0.01f; + mass = 1.5f; weapon = Weapons.chainBlaster; isFlying = true; health = 70; diff --git a/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java b/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java index 36be5fdc71..8d16feb64a 100644 --- a/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/TurretBlocks.java @@ -190,8 +190,8 @@ public class TurretBlocks extends BlockList implements ContentList{ cyclone = new ItemTurret("cyclone"){{ ammoTypes = new AmmoType[]{AmmoTypes.flakExplosive, AmmoTypes.flakPlastic, AmmoTypes.flakSurge}; xRand = 4f; - reload = 10f; - range = 140f; + reload = 8f; + range = 145f; size = 3; recoil = 3f; rotatespeed = 10f; diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index 38cc8e3dcc..b21dcb9e5a 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -206,8 +206,8 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ velocity.limit(getMaxVelocity()).scl(status.getSpeedMultiplier()); if(isFlying()){ - x += velocity.x / getMass() * Timers.delta(); - y += velocity.y / getMass() * Timers.delta(); + x += velocity.x * Timers.delta(); + y += velocity.y * Timers.delta(); }else{ boolean onLiquid = floor.isLiquid; diff --git a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java index 4910df3a40..484f1c735f 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java @@ -68,7 +68,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT bullet.type = type; bullet.lifeScl = lifetimeScl; - bullet.set(x, y); + bullet.set(x - bullet.velocity.x * Timers.delta(), y - bullet.velocity.y * Timers.delta()); bullet.add(); return bullet; @@ -192,7 +192,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT super.update(); if(type.hitTiles && collidesTiles() && !supressCollision && initialized){ - world.raycastEach(world.toTile(x), world.toTile(y), world.toTile(x + velocity.x), world.toTile(y + velocity.y), (x, y) -> { + world.raycastEach(world.toTile(lastPosition().x), world.toTile(lastPosition().y), world.toTile(x), world.toTile(y), (x, y) -> { Tile tile = world.tile(x, y); if(tile == null) return false; diff --git a/core/src/io/anuke/mindustry/entities/units/GroundUnit.java b/core/src/io/anuke/mindustry/entities/units/GroundUnit.java index ec71951c0f..b0d5aab067 100644 --- a/core/src/io/anuke/mindustry/entities/units/GroundUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/GroundUnit.java @@ -125,6 +125,10 @@ public abstract class GroundUnit extends BaseUnit{ rotation = Mathf.slerpDelta(rotation, velocity.angle(), type.rotatespeed); } + if(!velocity.isZero()){ + baseRotation = Mathf.slerpDelta(baseRotation, velocity.angle(), 0.05f); + } + if(stuckTime < 1f){ walkTime += Timers.delta(); } @@ -268,10 +272,7 @@ public abstract class GroundUnit extends BaseUnit{ if(tile == targetTile) return; - vec.trns(baseRotation, type.speed); - - baseRotation = Mathf.slerpDelta(baseRotation, angleTo(targetTile), 0.05f); - velocity.add(vec); + velocity.add(vec.trns(angleTo(targetTile), type.speed)); } protected void moveAwayFromCore(){ @@ -292,9 +293,6 @@ public abstract class GroundUnit extends BaseUnit{ if(tile == targetTile || core == null || distanceTo(core) < 90f) return; - vec.trns(baseRotation, type.speed); - - baseRotation = Mathf.slerpDelta(baseRotation, angleTo(targetTile), 0.05f); - velocity.add(vec); + velocity.add(vec.trns(angleTo(targetTile), type.speed)); } } diff --git a/core/src/io/anuke/mindustry/type/Mech.java b/core/src/io/anuke/mindustry/type/Mech.java index d616e02aec..92c11cfdf4 100644 --- a/core/src/io/anuke/mindustry/type/Mech.java +++ b/core/src/io/anuke/mindustry/type/Mech.java @@ -20,7 +20,7 @@ public class Mech extends UnlockableContent{ public boolean flying; public float speed = 1.1f; - public float maxSpeed = 1.1f; + public float maxSpeed = 10f; public float boostSpeed = 0.75f; public float drag = 0.4f; public float mass = 1f;