Skip to content

Commit 66b2cab

Browse files
Added configs for instability
1 parent 19dd06e commit 66b2cab

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

common/src/main/kotlin/org/valkyrienskies/eureka/EurekaConfig.kt

+8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ object EurekaConfig {
120120
@JsonSchema(description = "How fast a ship will stop. 1 = fast stop, 0 = slow stop")
121121
var linearStabilizeMaxAntiVelocity = 1.0
122122

123+
// Instability scaled with mass and squared speed
124+
@JsonSchema(description = "Stronger stabilization with higher mass, less at higher speeds.")
125+
var scaledInstability = 1000.0
126+
127+
// Unscaled linear instability cased by speed
128+
@JsonSchema(description = "Less stabilization at higher speed.")
129+
var unscaledInstability = 0.271828
130+
123131
@JsonSchema(description = "How fast a ship will stop and accelerate.")
124132
var linearMassScaling = 0.0002
125133

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ fun stabilize(
4949

5050
val speed = ship.poseVel.vel.length()
5151

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))
52+
stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant / max(1.0, speed * speed * EurekaConfig.SERVER.scaledInstability / ship.inertia.shipMass + speed * EurekaConfig.SERVER.unscaledInstability))
5653
forces.applyInvariantTorque(stabilizationTorque)
5754

5855
if (linear) {

0 commit comments

Comments
 (0)