Skip to content

Commit 19dd06e

Browse files
committed
Speed and mass dependent stabilization. Mostly exists to nerf scooters.
1 parent 99b6129 commit 19dd06e

File tree

1 file changed

+7
-1
lines changed
  • common/src/main/kotlin/org/valkyrienskies/eureka/ship

1 file changed

+7
-1
lines changed

common/src/main/kotlin/org/valkyrienskies/eureka/ship/Stabilize.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.valkyrienskies.core.api.ships.PhysShip
66
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
77
import org.valkyrienskies.eureka.EurekaConfig
88
import kotlin.math.atan
9+
import kotlin.math.max
910

1011
fun stabilize(
1112
ship: PhysShipImpl,
@@ -46,7 +47,12 @@ fun stabilize(
4647
)
4748
)
4849

49-
stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant)
50+
val speed = ship.poseVel.vel.length()
51+
52+
val multiplierA = 1000f; // 1 kilo
53+
val multiplierB = 0.271828; // e / 10
54+
55+
stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant / max(1.0, speed * speed * multiplierA / ship.inertia.shipMass + speed * multiplierB))
5056
forces.applyInvariantTorque(stabilizationTorque)
5157

5258
if (linear) {

0 commit comments

Comments
 (0)