Class PlayerMovement
Namespace: ValveResourceFormat.Renderer.Input
Assembly: Renderer.dll
Closed-form, framerate-independent solvers for ground movement under combined friction and acceleration: the walk-taper band and the no-prestrafe speed cap.
public class PlayerMovement : IPlayerControllerInheritance
Implements
Constructors
PlayerMovement(UserInput)
Initializes a new bound to the given user input source.
public PlayerMovement(UserInput input)Parameters
input UserInput
The user input instance used to read key state.
Fields
AirAccelerateCompetitive
sv_airaccelerate for competitive play.
public const float AirAccelerateCompetitive = 12Field Value
AirAccelerateMovementMaps
sv_airaccelerate for movement maps, far above the engine default so surf and strafe maps have air control.
public const float AirAccelerateMovementMaps = 150Field Value
Properties
AirAccelerate
Gets or sets sv_airaccelerate, the air-control acceleration rate.
public float AirAccelerate { get; set; }Property Value
AutoBunnyHop
Gets or sets a value indicating whether bunny-hopping is allowed by holding the jump key.
public bool AutoBunnyHop { get; set; }Property Value
BlendedEyeHeight
Gets the current eye height blended between standing and crouched positions.
public float BlendedEyeHeight { get; }Property Value
CrouchBlend
Linear value from 0 to 1 representing how much the player is crouched. 0 = standing, 1 = fully crouched.
public float CrouchBlend { get; }Property Value
DebugCollisionPlanes
Test-only extra static collision half-spaces layered onto the traces, each a
whose XYZ is the outward unit normal and W the plane offset d;the half-space n·x ≤ d is solid. Lets headless tests build walls and overhangs without a physics world. Empty in normal use.
public List<Vector4> DebugCollisionPlanes { get; }Property Value
EmulatedTickRate
Gets or sets the tick rate whose per-tick acceleration step the tickless integrators reproduce. A discrete engine tops the wishdir velocity component up by at most the whole remaining addspeed once per tick, which is a bound on speed gained per unit time; the continuous forms reimpose that bound so they converge to the same trajectory instead of out-accelerating the reference engine as the frame time shrinks.
public float EmulatedTickRate { get; set; }Property Value
EyePosition
The current eye position
public Vector3 EyePosition { get; }Property Value
GridPlaneCollisionEnabled
Gets or sets a value indicating whether traces also collide with an infinite ground plane at Z=0.
public bool GridPlaneCollisionEnabled { get; set; }Property Value
GroundEntity
Gets the entity the player stands on - a brush entity, or the worldspawn on the map itself - and null in the air. The engine's m_hGroundEntity, taken from the ground probe every frame.
public BaseEntity? GroundEntity { get; }Property Value
HullHalfExtents
Gets the current collision hull half-extents, with height blended between the standing and ducked hulls by .
public Vector3 HullHalfExtents { get; }Property Value
Initialize
Gets or sets a value indicating whether the controller should reinitialize its position from the camera on the next tick.
public bool Initialize { get; set; }Property Value
IsActive
Gets whether the player is being simulated - the viewer's walk mode.
public bool IsActive { get; }Property Value
JumpImpulse
Upward velocity the last jump left the ground with, after stamina.
public float JumpImpulse { get; }Property Value
Jumped
Whether a jump left the ground this frame. Leaving it any other way does not count.
public bool Jumped { get; }Property Value
OnGround
Gets a value indicating whether the player is currently on the ground.
public bool OnGround { get; }Property Value
PendingPush
Gets the reserved push the controller has not walked yet. A rider's carry is computed at
plus this, so each tick targets the exact carried trajectory and thewalk-off lag cannot accumulate into drift.
public Vector3 PendingPush { get; }Property Value
Position
Gets the current player position at feet level (where the AABB touches the ground).
public Vector3 Position { get; }Property Value
PrestrafeEnabled
Gets or sets a value indicating whether ground pre-strafe is allowed.
public bool PrestrafeEnabled { get; set; }Property Value
RideVelocity
Gets the velocity of the mover currently carrying the player, zero on still ground. Riding is positional, so never contains it.
public Vector3 RideVelocity { get; }Property Value
RunSpeed
Gets or sets the base run speed in world units per second.
public float RunSpeed { get; set; }Property Value
Stamina
Gets the current jump stamina, from 0 to 1. Landing drains it, it recovers over roughly a second, and jump impulses scale by it, so spammed hops get progressively lower (like CS's sv_stamina behavior).
public float Stamina { get; }Property Value
StepSmoothingEnabled
Gets or sets a value indicating whether the view glides up and down stair steps instead of popping.
public bool StepSmoothingEnabled { get; set; }Property Value
Velocity
Gets the current player velocity in world units per second.
public Vector3 Velocity { get; }Property Value
ViewForward
Gets the direction the player is looking.
public Vector3 ViewForward { get; }Property Value
ViewPunchDecay
Gets or sets view_punch_decay, the exponential rate the landing punch recovers at.
public float ViewPunchDecay { get; set; }Property Value
ViewPunchPitchDegrees
Gets the downward view punch from the last landing, in degrees. This is additive on top of the player's aim for rendering only, exactly like Source's m_viewPunchAngle.
public float ViewPunchPitchDegrees { get; }Property Value
WasOnGroundLastFrame
Gets a value indicating whether the player was touching the ground in the previous frame.
public bool WasOnGroundLastFrame { get; }Property Value
Methods
CacheSounds()
Pre-decodes the sounds movement can fire, so the first step does not decode mid-frame.
public static void CacheSounds()ConsumeButtons()
Takes the buttons seen since the last call, reporting them against the state the previous call left. Called once per tick, by the player entity.
public PlayerButtonState ConsumeButtons()Returns
What is held, and what changed, for the tick collecting it.
ProcessMovement(Camera, float)
Runs the movement simulation once per rendered frame, mirroring Source's frame order.
public void ProcessMovement(Camera camera, float deltaTime)Parameters
camera Camera
deltaTime float
Push(Vector3, bool)
Shoves the player by a pusher's tick displacement, stopped early by the static world. Runs on the entity tick. A ride carry is reserved and walked off as real motion spread over the following interval, so riders move with the pusher's rendered sweep instead of stepping at the tick rate; a depenetrating shove lands immediately, so the hull never dwells inside the pusher.
public Vector3 Push(Vector3 delta, bool immediate = false)Parameters
delta Vector3
immediate bool
Returns
ResetPosition(Camera)
Reinitialize the character position from the current camera location. Call this when switching from noclip to FPS movement mode.
public void ResetPosition(Camera camera)Parameters
camera Camera
Teleport(Vector3, Vector3?)
Moves the player somewhere else outright, keeping their velocity.
public void Teleport(Vector3 feetPosition, Vector3? angles)Parameters
feetPosition Vector3
Where the feet arrive.
angles Vector3?
View angles to adopt, or null to keep the current one.

