Skip to content

Commit

Permalink
Speed and mass dependent stabilization. Mostly exists to nerf scooters.
Browse files Browse the repository at this point in the history
  • Loading branch information
copperwarrior committed May 24, 2024
1 parent 99b6129 commit 19dd06e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.valkyrienskies.core.api.ships.PhysShip
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
import org.valkyrienskies.eureka.EurekaConfig
import kotlin.math.atan
import kotlin.math.max

fun stabilize(
ship: PhysShipImpl,
Expand Down Expand Up @@ -46,7 +47,12 @@ fun stabilize(
)
)

stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant)
val speed = ship.poseVel.vel.length()

val multiplierA = 1000f; // 1 kilo
val multiplierB = 0.271828; // e / 10

stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant / max(1.0, speed * speed * multiplierA / ship.inertia.shipMass + speed * multiplierB))
forces.applyInvariantTorque(stabilizationTorque)

if (linear) {
Expand Down

0 comments on commit 19dd06e

Please sign in to comment.