File tree 2 files changed +12
-1
lines changed
common/src/main/kotlin/org/valkyrienskies/eureka
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,14 @@ object EurekaConfig {
120
120
@JsonSchema(description = " How fast a ship will stop. 1 = fast stop, 0 = slow stop" )
121
121
var linearStabilizeMaxAntiVelocity = 1.0
122
122
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
+
123
131
@JsonSchema(description = " How fast a ship will stop and accelerate." )
124
132
var linearMassScaling = 0.0002
125
133
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import org.valkyrienskies.core.api.ships.PhysShip
6
6
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
7
7
import org.valkyrienskies.eureka.EurekaConfig
8
8
import kotlin.math.atan
9
+ import kotlin.math.max
9
10
10
11
fun stabilize (
11
12
ship : PhysShipImpl ,
@@ -46,7 +47,9 @@ fun stabilize(
46
47
)
47
48
)
48
49
49
- stabilizationTorque.mul(EurekaConfig .SERVER .stabilizationTorqueConstant)
50
+ val speed = ship.poseVel.vel.length()
51
+
52
+ stabilizationTorque.mul(EurekaConfig .SERVER .stabilizationTorqueConstant / max(1.0 , speed * speed * EurekaConfig .SERVER .scaledInstability / ship.inertia.shipMass + speed * EurekaConfig .SERVER .unscaledInstability))
50
53
forces.applyInvariantTorque(stabilizationTorque)
51
54
52
55
if (linear) {
You can’t perform that action at this time.
0 commit comments