moving platforms can 'steal' actors

This commit is contained in:
minjaesong
2026-02-09 02:34:49 +09:00
parent 5394f17686
commit 855e0ea12a

View File

@@ -133,18 +133,29 @@ abstract class PhysContraption() : ActorWithBody() {
INGAME.actorNowPlaying?.let { candidates.add(it) } INGAME.actorNowPlaying?.let { candidates.add(it) }
for (actor in candidates) { for (actor in candidates) {
if (!actorsRiding.contains(actor.referenceID) && actor.platformsRiding.isEmpty() && isActorOnTop(actor)) { if (actorsRiding.contains(actor.referenceID)) continue
mount(actor) if (!isActorOnTop(actor)) continue
snapRiderToSurface(actor)
// Landing on the contraption kills all vertical velocity. // If already riding another contraption, only steal if this
// controllerV.y must also be zeroed: during a jump-then-fall, // surface is strictly above (smaller Y) to prevent oscillation.
// controllerV.y stays negative (jump impulse) while externalV.y if (actor.platformsRiding.isNotEmpty()) {
// goes positive (gravity). Zeroing only externalV.y would leave val currentPlatform = INGAME.getActorByID(actor.platformsRiding[0]) as? PhysContraption
// a net upward velocity that immediately triggers dismount. if (currentPlatform != null && hitbox.startY >= currentPlatform.hitbox.startY) continue
actor.externalV.y = 0.0 // Transfer: remove from old contraption without velocity impulse
actor.controllerV?.let { it.y = 0.0 } currentPlatform?.actorsRiding?.remove(actor.referenceID)
actor.walledBottom = true actor.platformsRiding.clear()
} }
mount(actor)
snapRiderToSurface(actor)
// Landing on the contraption kills all vertical velocity.
// controllerV.y must also be zeroed: during a jump-then-fall,
// controllerV.y stays negative (jump impulse) while externalV.y
// goes positive (gravity). Zeroing only externalV.y would leave
// a net upward velocity that immediately triggers dismount.
actor.externalV.y = 0.0
actor.controllerV?.let { it.y = 0.0 }
actor.walledBottom = true
} }
} }