Restore original airborne steering for jumps and jetpack bursts
This commit is contained in:
1 parent
b58138d7ba
commit
976e677019
16 files changed
+357
-54
No files matched your search
@@ -7,7 +7,7 @@ public readonly record struct PlayerInput(bool Forward, bool Backward, bool Left
|
||||
public enum PlayerPose { Idle, Run, Backpedal, Jump, Fall, Fly }
|
||||
|
||||
/// <summary>
|
||||
/// No-gadget walking checkpoint. Recovered input/arithmetic is described in
|
||||
/// Walking, airborne steering and jetpack checkpoint. Recovered arithmetic is described in
|
||||
/// movement-checkpoint.md. Capsule, floor-derived pivot and 60Hz are port policies;
|
||||
/// original collision, intro, object interactions and animation timing remain open.
|
||||
/// </summary>
|
||||
@@ -33,6 +33,7 @@ public sealed class LabSimulation
|
||||
public Vector3 Velocity { get; private set; }
|
||||
public float Yaw { get; private set; }
|
||||
public float Speed { get; private set; }
|
||||
public float TurnRate { get; private set; }
|
||||
public bool Grounded { get; private set; }
|
||||
public PlayerPose Pose => Grounded ? Speed < -1 ? PlayerPose.Backpedal : Speed > 1 ? PlayerPose.Run : PlayerPose.Idle
|
||||
: jumpState.JumpState == 3 && jumpState.EffectRemaining > 0 ? PlayerPose.Fly
|
||||
@@ -74,7 +75,7 @@ public sealed class LabSimulation
|
||||
Position = new(sourceStart.X, floor + SceneCollision.Skin, sourceStart.Z);
|
||||
Velocity = Vector3.Zero;
|
||||
Yaw = targetYaw = startYaw;
|
||||
Speed = extraAirAcceleration = shadowDistance = 0;
|
||||
Speed = TurnRate = extraAirAcceleration = shadowDistance = 0;
|
||||
jumpState = default;
|
||||
forceFall = JetpackEffectVisible = false;
|
||||
InteractionRadius = 60; Bursts = 0;
|
||||
@@ -109,11 +110,25 @@ public sealed class LabSimulation
|
||||
if (input.Backward) Speed = MathF.Max(Speed - 52.5f, -300);
|
||||
else if (!input.Forward) Speed = RecoveredMotion.ReleaseSpeed(Speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
var steering = AirSteering.Step(Speed, TurnRate, input, dt);
|
||||
Speed = steering.Speed; TurnRate = steering.TurnRate;
|
||||
//439E2B preserves current yaw as the destination; air apply then
|
||||
//438011..43802B adds the independent turn rate directly to yaw.
|
||||
targetYaw = Yaw;
|
||||
}
|
||||
var yawError = MathF.IEEERemainder(targetYaw - Yaw, 360);
|
||||
Yaw = (Yaw + yawError * dt * 3.7f) % 360;
|
||||
if (Velocity.LengthSquared() != 0 || Grounded && lateral != 0)
|
||||
Yaw = (Yaw + TurnRate * dt) % 360;
|
||||
var (sin, cos) = Trig(Yaw);
|
||||
var velocity = new Vector3(-sin * Speed, Velocity.Y, cos * Speed);
|
||||
if (Grounded) velocity += new Vector3(cos, 0, sin) * (lateral * dt);
|
||||
//437CDx ground uses /45 then dt;43803B air uses /55 without dt.
|
||||
const float friction = .8f;
|
||||
var sideSpeed = Grounded ? (TurnRate * (1 - friction) * Speed / 45 + lateral) * dt
|
||||
: TurnRate * (1 - friction) * Speed * .0181818176060915f;
|
||||
velocity += new Vector3(cos, 0, sin) * sideSpeed;
|
||||
if (collision.GroundHeight(ActorRoot, 2500) is { } shadowFloor)
|
||||
shadowDistance = MathF.Abs(ActorRoot.Y - shadowFloor - 13);
|
||||
var air = JetpackBurst.Step(jumpState, new(Grounded, input.Jump, velocity.Y, shadowDistance,
|
||||
@@ -170,6 +185,9 @@ public sealed class LabSimulation
|
||||
public static PlayerInput SmokeInput(int step) => new(step < 120, false, false,
|
||||
step >= 120 && step < 180, step >= 72 && step < 84);
|
||||
|
||||
public static PlayerInput JetpackSmokeInput(int step) => new(step is >= 45 and < 80,
|
||||
step is >= 80 and < 120, step is >= 60 and < 95, false, step < 180);
|
||||
|
||||
public bool SmokePassed => Steps >= 240 && Travel > 50 && MaximumRise > 20 && Jumps > 0 && Landings > 0 && Grounded;
|
||||
public string Report => $"Walk checkpoint: steps={Steps}, travel={Travel:F2}, jumps={Jumps}, landings={Landings}, max rise={MaximumRise:F2}, wall hits={WallHits}, grounded={Grounded}, feet={Position}.";
|
||||
}
|
||||
Reference in new issue
Block a user