PlayerControllerclass

object→Component→PlayerController
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.PlayerController : Sandbox.Component

Constructors1

Showing 1 constructors

Methods14

Showing 14 methods

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

Return an aabb representing the body

ParameterTypeDescription
scale = 1float—
heightScale = 1float—
Returns:BBox—

public void CreateBodyRenderer()PUBLIC

Create a child renderer using the Human model for the player's body.

Returns:void—

public Sandbox.GameObject CreateRagdoll(string name = Ragdoll)PUBLIC

Create a ragdoll gameobject version of our render body.

ParameterTypeDescription
name = Ragdollstring—
Returns:GameObject—

public void Jump(Vector3 velocity)PUBLIC

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.

ParameterTypeDescription
velocityVector3—
Returns:void—

public void OnJumped()PUBLIC

Returns:void—

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

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

ParameterTypeDescription
worldPositionVector3—
volumefloat—
footint—
Returns:void—

public void PreventGrounding(float seconds)PUBLIC

Prevent being grounded for a number of seconds

ParameterTypeDescription
secondsfloat—
Returns:void—

public void RestoreGrounding()PUBLIC

Restores grounding, meant to be called during PreventGrounding( float seconds )

Returns:void—

public void StartPressing(Sandbox.Component obj)PUBLIC

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

ParameterTypeDescription
objComponent—
Returns:void—

public void StopPressing()PUBLIC

Stop pressing. Pressed will become null.

Returns:void—

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

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

ParameterTypeDescription
fromVector3—
toVector3—
scale = 1float—
heightScale = 1float—
Returns:SceneTraceResult—

public void UpdateAnimation(Sandbox.SkinnedModelRenderer renderer)PUBLICPER-FRAME

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

ParameterTypeDescription
rendererSkinnedModelRenderer—
Returns:void—

public void UpdateDucking(bool wantsDuck)PUBLICPER-FRAME

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

ParameterTypeDescription
wantsDuckbool—
Returns:void—

public void UpdateLookAt()PUBLICPER-FRAME

Called in Update when Using is enabled

Returns:void—

Properties76

Showing 76 properties

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

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

Returns:float—

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

How strongly to turn in the eye direction with our body

Returns:float—

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

How strongly to look in the eye direction with our eyes

Returns:float—

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

How strongly to turn in the eye direction with our head

Returns:float—

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

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

Returns:float—

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

The button that the player will press to use to run

Returns:string—

public float Sandbox.PlayerController.BodyHeight { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.PlayerController.BodyMass { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.PlayerController.BodyRadius { get; set; }PUBLICGETSET

Returns:float—

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

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.

Returns:float—

public Sandbox.TagSet Sandbox.PlayerController.CameraCollisionIgnore { get; set; }PUBLICGETSET

The set of tags to ignore during camera collision detection.

Returns:TagSet—

public virtual int Sandbox.PlayerController.ComponentVersion { get; set; }PUBLICVIRTUALGETSET

Returns:int—

public float Sandbox.PlayerController.CoyoteTime { get; set; }PUBLICGETSET

How many seconds after leaving the ground the player can still jump. Set to 0 to disable.

Returns:float—

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

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

Returns:float—

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

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

Returns:float—

public float Sandbox.PlayerController.DuckedHeight { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.PlayerController.DuckedSpeed { get; set; }PUBLICGETSET

Returns:float—

public bool Sandbox.PlayerController.EnableFootstepSounds { get; set; }PUBLICGETSET

Returns:bool—

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

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

Returns:bool—

public float Sandbox.PlayerController.EyeDistanceFromTop { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.PlayerController.FootstepVolume { get; set; }PUBLICGETSET

Returns:float—

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

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

Returns:Component—

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

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

Returns:float—

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

Are we standing on a surface that is physically dynamic

Returns:bool—

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

The velocity that the ground underneath us is moving

Returns:Vector3—

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

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

Returns:float—

public bool Sandbox.PlayerController.HideBodyInFirstPerson { get; set; }PUBLICGETSET

Returns:bool—

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

Not touching the ground, and not swimming or climbing

Returns:bool—

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

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

Returns:bool—

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

True if this player is ducking

Returns:bool—

public bool Sandbox.PlayerController.IsOnGround { get; set; }PUBLICGETSET

Returns:bool—

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

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

Returns:bool—

public float Sandbox.PlayerController.JumpSpeed { get; set; }PUBLICGETSET

Returns:float—

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

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

Returns:float—

public float Sandbox.PlayerController.PitchClamp { get; set; }PUBLICGETSET

Returns:float—

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

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

Returns:float—

public bool Sandbox.PlayerController.RotateWithGround { get; set; }PUBLICGETSET

Returns:bool—

public float Sandbox.PlayerController.RotationAngleLimit { get; set; }PUBLICGETSET

Returns:float—

public float Sandbox.PlayerController.RotationSpeed { get; set; }PUBLICGETSET

Returns:float—

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

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

Returns:bool—

public float Sandbox.PlayerController.RunSpeed { get; set; }PUBLICGETSET

Returns:float—

public bool Sandbox.PlayerController.ShowColliderComponents { get; set; }PUBLICGETSET

Returns:bool—

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

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

Returns:bool—

public bool Sandbox.PlayerController.ShowRigidbodyComponent { get; set; }PUBLICGETSET

Returns:bool—

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

Enable debug overlays for this character.

Returns:bool—

public bool Sandbox.PlayerController.ThirdPerson { get; set; }PUBLICGETSET

Returns:bool—

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

Amount of time since this character was last on the ground

Returns:TimeSince—

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

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

Returns:TimeSince—

public string Sandbox.PlayerController.ToggleCameraModeButton { get; set; }PUBLICGETSET

Returns:string—

public bool Sandbox.PlayerController.UseAnimatorControls { get; set; }PUBLICGETSET

Returns:bool—

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

The button that the player will press to use things

Returns:string—

public bool Sandbox.PlayerController.UseCameraControls { get; set; }PUBLICGETSET

Returns:bool—

public bool Sandbox.PlayerController.UseFovFromPreferences { get; set; }PUBLICGETSET

Returns:bool—

public bool Sandbox.PlayerController.UseInputControls { get; set; }PUBLICGETSETINGEST

Returns:bool—

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

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

Returns:bool—

public float Sandbox.PlayerController.WalkSpeed { get; set; }PUBLICGETSET

Returns:float—

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 RestoreGrounding()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 Sandbox.TagSet Sandbox.PlayerController.CameraCollisionIgnore { get; set; }public Vector3 Sandbox.PlayerController.CameraOffset { get; set; }public Sandbox.GameObject Sandbox.PlayerController.ColliderObject { get; set; }public virtual System.Int32 Sandbox.PlayerController.ComponentVersion { get; set; }public System.Single Sandbox.PlayerController.CoyoteTime { 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 Vector3 Sandbox.PlayerController.GroundNormal { 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