s&box docs

public sealed class Sandbox.PlayerController : Sandbox.Component

Broader workflow and conceptual references connected to this API.

Constructors

Showing 1 constructors

Methods

Showing 13 methods

public BBox BodyBox(float scale = 1, float heightScale = 1)

Return an aabb representing the body

Parameters

  • scale: Default: 1
  • heightScale: Default: 1

public void CreateBodyRenderer()

public Sandbox.GameObject CreateRagdoll(string name = Ragdoll)

Create a ragdoll gameobject version of our render body.

Parameters

  • name: Default: Ragdoll

public void Jump(Vector3 velocity)

Adds velocity in a special way. First we subtract any opposite velocity (ie, falling) then we add the velocity, but we clamp it to that direction. This means that if you jump when you're running up a platform, you don't get extra jump power.

public void OnJumped()

public void PlayFootstepSound(Vector3 worldPosition, float volume, int foot)

Play a footstep sound at the given world position. Will only play if the player has a GroundSurface.

public void PreventGrounding(float seconds)

Prevent being grounded for a number of seconds

public void StartPressing(Sandbox.Component obj)

Start pressing a target component. This is called automatically when Use is pressed.

public void StopPressing()

Stop pressing. Pressed will become null.

public Sandbox.SceneTraceResult TraceBody(Vector3 from, Vector3 to, float scale = 1, float heightScale = 1)

Trace the aabb body from one position to another and return the result

Parameters

  • scale: Default: 1
  • heightScale: Default: 1

public void UpdateAnimation(Sandbox.SkinnedModelRenderer renderer)

Update the animation for this renderer. This will update the body rotation etc too.

public void UpdateDucking(bool wantsDuck)

Called during FixedUpdate when UseInputControls is enabled. Will duck if requested. If not, and we're ducked, will unduck if there is room

public void UpdateLookAt()

Called in Update when Using is enabled

Properties

Showing 72 properties

public float Sandbox.PlayerController.AccelerationTime { get; set; }

Amount of seconds it takes to get from your current speed to your requuested speed, if higher

public float Sandbox.PlayerController.AimStrengthBody { get; set; }

How strongly to turn in the eye direction with our body

public float Sandbox.PlayerController.AimStrengthEyes { get; set; }

How strongly to look in the eye direction with our eyes

public float Sandbox.PlayerController.AimStrengthHead { get; set; }

How strongly to turn in the eye direction with our head

public float Sandbox.PlayerController.AirFriction { get; set; }

How much friction to add when we're in the air. This will slow you down unless you have a wish velocity.

public string Sandbox.PlayerController.AltMoveButton { get; set; }

The button that the player will press to use to run

public float Sandbox.PlayerController.BrakePower { get; set; }

We will apply extra friction when we're on the ground and our desired velocity is lower than our current velocity, so we will slow down.

public float Sandbox.PlayerController.CurrentHeight { get; set; }

Gets the current character height from `Sandbox.PlayerController.BodyHeight` when standing, otherwise uses `Sandbox.PlayerController.DuckedHeight` when ducking.

public float Sandbox.PlayerController.DeaccelerationTime { get; set; }

Amount of seconds it takes to get from your current speed to your requuested speed, if lower

public bool Sandbox.PlayerController.EnablePressing { get; set; }

Allows to player to interact with things by "use"ing them. Usually by pressing the "use" button.

public Sandbox.Component Sandbox.PlayerController.GroundComponent { get; set; }

The collider component we're standing on. Null if we're standing nothing

public float Sandbox.PlayerController.GroundFriction { get; set; }

The friction property of the ground we're standing on.

public bool Sandbox.PlayerController.GroundIsDynamic { get; set; }

Are we standing on a surface that is physically dynamic

public Sandbox.GameObject Sandbox.PlayerController.GroundObject { get; set; }

The object we're standing on. Null if we're standing on nothing.

public Sandbox.Surface Sandbox.PlayerController.GroundSurface { get; set; }

If we're stnding on a surface this is it

public Vector3 Sandbox.PlayerController.GroundVelocity { get; set; }

The velocity that the ground underneath us is moving

public float Sandbox.PlayerController.Headroom { get; set; }

The distance from the top of the head to the closest ceiling.

public bool Sandbox.PlayerController.IsAirborne { get; set; }

Not touching the ground, and not swimming or climbing

public bool Sandbox.PlayerController.IsClimbing { get; set; }

Set to true when entering a climbing `Sandbox.Movement.MoveMode`.

public bool Sandbox.PlayerController.IsDucking { get; set; }

True if this player is ducking

public bool Sandbox.PlayerController.IsSwimming { get; set; }

Set to true when entering a swimming `Sandbox.Movement.MoveMode`.

public float Sandbox.PlayerController.LookSensitivity { get; set; }

Allows modifying the eye angle sensitivity. Note that player preference sensitivity is already automatically applied, this is just extra.

public float Sandbox.PlayerController.ReachLength { get; set; }

How far from the eye can the player reach to use things

public bool Sandbox.PlayerController.RunByDefault { get; set; }

If true then the player will run by default, and holding AltMoveButton will switch to walk

public bool Sandbox.PlayerController.ShowCreateBodyRenderer { get; set; }

If true we'll show the "create body" button

public bool Sandbox.PlayerController.StepDebug { get; set; }

Enable debug overlays for this character

public Sandbox.TimeSince Sandbox.PlayerController.TimeSinceGrounded { get; set; }

Amount of time since this character was last on the ground

public Sandbox.TimeSince Sandbox.PlayerController.TimeSinceUngrounded { get; set; }

Amount of time since this character was last not on the ground

public string Sandbox.PlayerController.UseButton { get; set; }

The button that the player will press to use things

public bool Sandbox.PlayerController.UseLookControls { get; set; }

When true we'll move the camera around using the mouse

public Vector3 Sandbox.PlayerController.Velocity { get; set; }

Our actual physical velocity minus our ground velocity

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.PlayerController

On this page

Constructorspublic PlayerController()Methodspublic BBox BodyBox(System.Single scale = 1, System.Single heightScale = 1)public System.Void CreateBodyRenderer()public Sandbox.GameObject CreateRagdoll(System.String name = Ragdoll)public System.Void Jump(Vector3 velocity)public System.Void OnJumped()public System.Void PlayFootstepSound(Vector3 worldPosition, System.Single volume, System.Int32 foot)public System.Void PreventGrounding(System.Single seconds)public System.Void StartPressing(Sandbox.Component obj)public System.Void StopPressing()public Sandbox.SceneTraceResult TraceBody(Vector3 from, Vector3 to, System.Single scale = 1, System.Single heightScale = 1)public System.Void UpdateAnimation(Sandbox.SkinnedModelRenderer renderer)public System.Void UpdateDucking(System.Boolean wantsDuck)public System.Void UpdateLookAt()Propertiespublic System.Single Sandbox.PlayerController.AccelerationTime { get; set; }public System.Single Sandbox.PlayerController.AimStrengthBody { get; set; }public System.Single Sandbox.PlayerController.AimStrengthEyes { get; set; }public System.Single Sandbox.PlayerController.AimStrengthHead { get; set; }public System.Single Sandbox.PlayerController.AirFriction { get; set; }public System.String Sandbox.PlayerController.AltMoveButton { get; set; }public Sandbox.Rigidbody Sandbox.PlayerController.Body { get; set; }public Sandbox.CapsuleCollider Sandbox.PlayerController.BodyCollider { get; set; }public Sandbox.TagSet Sandbox.PlayerController.BodyCollisionTags { get; set; }public System.Single Sandbox.PlayerController.BodyHeight { get; set; }public System.Single Sandbox.PlayerController.BodyMass { get; set; }public System.Single Sandbox.PlayerController.BodyRadius { get; set; }public System.Single Sandbox.PlayerController.BrakePower { get; set; }public Vector3 Sandbox.PlayerController.CameraOffset { get; set; }public Sandbox.GameObject Sandbox.PlayerController.ColliderObject { get; set; }public System.Single Sandbox.PlayerController.CurrentHeight { get; set; }public System.Single Sandbox.PlayerController.DeaccelerationTime { get; set; }public System.Single Sandbox.PlayerController.DuckedHeight { get; set; }public System.Single Sandbox.PlayerController.DuckedSpeed { get; set; }public System.Boolean Sandbox.PlayerController.EnableFootstepSounds { get; set; }public System.Boolean Sandbox.PlayerController.EnablePressing { get; set; }public Angles Sandbox.PlayerController.EyeAngles { get; set; }public System.Single Sandbox.PlayerController.EyeDistanceFromTop { get; set; }public Vector3 Sandbox.PlayerController.EyePosition { get; set; }public Transform Sandbox.PlayerController.EyeTransform { get; set; }public Sandbox.BoxCollider Sandbox.PlayerController.FeetCollider { get; set; }public Sandbox.Audio.MixerHandle Sandbox.PlayerController.FootstepMixer { get; set; }public System.Single Sandbox.PlayerController.FootstepVolume { get; set; }public Sandbox.Component Sandbox.PlayerController.GroundComponent { get; set; }public System.Single Sandbox.PlayerController.GroundFriction { get; set; }public System.Boolean Sandbox.PlayerController.GroundIsDynamic { get; set; }public Sandbox.GameObject Sandbox.PlayerController.GroundObject { get; set; }public Sandbox.Surface Sandbox.PlayerController.GroundSurface { get; set; }public Vector3 Sandbox.PlayerController.GroundVelocity { get; set; }public System.Single Sandbox.PlayerController.Headroom { get; set; }public System.Boolean Sandbox.PlayerController.HideBodyInFirstPerson { get; set; }public Sandbox.Component Sandbox.PlayerController.Hovered { get; set; }public System.Boolean Sandbox.PlayerController.IsAirborne { get; set; }public System.Boolean Sandbox.PlayerController.IsClimbing { get; set; }public System.Boolean Sandbox.PlayerController.IsDucking { get; set; }public System.Boolean Sandbox.PlayerController.IsOnGround { get; set; }public System.Boolean Sandbox.PlayerController.IsSwimming { get; set; }public System.Single Sandbox.PlayerController.JumpSpeed { get; set; }public System.Single Sandbox.PlayerController.LookSensitivity { get; set; }public Sandbox.Movement.MoveMode Sandbox.PlayerController.Mode { get; set; }public System.Single Sandbox.PlayerController.PitchClamp { get; set; }public Sandbox.Component Sandbox.PlayerController.Pressed { get; set; }public System.Single Sandbox.PlayerController.ReachLength { get; set; }public Sandbox.SkinnedModelRenderer Sandbox.PlayerController.Renderer { get; set; }public System.Boolean Sandbox.PlayerController.RotateWithGround { get; set; }public System.Single Sandbox.PlayerController.RotationAngleLimit { get; set; }public System.Single Sandbox.PlayerController.RotationSpeed { get; set; }public System.Boolean Sandbox.PlayerController.RunByDefault { get; set; }public System.Single Sandbox.PlayerController.RunSpeed { get; set; }public System.Boolean Sandbox.PlayerController.ShowColliderComponents { get; set; }public System.Boolean Sandbox.PlayerController.ShowCreateBodyRenderer { get; set; }public System.Boolean Sandbox.PlayerController.ShowRigidbodyComponent { get; set; }public System.Boolean Sandbox.PlayerController.StepDebug { get; set; }public System.Boolean Sandbox.PlayerController.ThirdPerson { get; set; }public Sandbox.TimeSince Sandbox.PlayerController.TimeSinceGrounded { get; set; }public Sandbox.TimeSince Sandbox.PlayerController.TimeSinceUngrounded { get; set; }public System.String Sandbox.PlayerController.ToggleCameraModeButton { get; set; }public System.Collections.Generic.List`1<Sandbox.Component.IPressable.Tooltip> Sandbox.PlayerController.Tooltips { get; set; }public System.Boolean Sandbox.PlayerController.UseAnimatorControls { get; set; }public System.String Sandbox.PlayerController.UseButton { get; set; }public System.Boolean Sandbox.PlayerController.UseCameraControls { get; set; }public System.Boolean Sandbox.PlayerController.UseFovFromPreferences { get; set; }public System.Boolean Sandbox.PlayerController.UseInputControls { get; set; }public System.Boolean Sandbox.PlayerController.UseLookControls { get; set; }public Vector3 Sandbox.PlayerController.Velocity { get; set; }public System.Single Sandbox.PlayerController.WalkSpeed { get; set; }public Vector3 Sandbox.PlayerController.WishVelocity { get; set; }Metadata