Api Sandbox PlayerController
class

PlayerController

public sealed class PlayerController : Component

Constructors

PlayerController()

Properties

Name Type Description
UseAnimatorControls Boolean
Renderer SkinnedModelRenderer The body will usually be a child object with SkinnedModelRenderer
ShowCreateBodyRenderer Boolean If true we'll show the "create body" button
RotationAngleLimit Single
RotationSpeed Single
EnableFootstepSounds Boolean
FootstepVolume Single
FootstepMixer MixerHandle
AimStrengthEyes Single How strongly to look in the eye direction with our eyes
AimStrengthHead Single How strongly to turn in the eye direction with our head
AimStrengthBody Single How strongly to turn in the eye direction with our body
UseCameraControls Boolean
EyeDistanceFromTop Single
ThirdPerson Boolean
HideBodyInFirstPerson Boolean
UseFovFromPreferences Boolean
CameraOffset Vector3
ToggleCameraModeButton String
Body Rigidbody
BodyCollider CapsuleCollider
FeetCollider BoxCollider
ColliderObject GameObject
BodyRadius Single
BodyHeight Single
BodyMass Single
BodyCollisionTags TagSet
BrakePower Single 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.
AirFriction Single How much friction to add when we're in the air. This will slow you down unless you have a wish velocity.
ShowRigidbodyComponent Boolean
ShowColliderComponents Boolean
WishVelocity Vector3
IsOnGround Boolean
IsAirborne Boolean Not touching the ground, and not swimming or climbing
Velocity Vector3 Our actual physical velocity minus our ground velocity
GroundVelocity Vector3 The velocity that the ground underneath us is moving
IsClimbing Boolean Set to true when entering a climbing MoveMode.
IsSwimming Boolean Set to true when entering a swimming MoveMode.
EyeAngles Angles The direction we're looking in input space.
EyePosition Vector3 The player's eye position, in first person mode
EyeTransform Transform The player's eye transform, in first person mode
IsDucking Boolean True if this player is ducking
Headroom Single The distance from the top of the head to the closest ceiling.
GroundObject GameObject The object we're standing on. Null if we're standing on nothing.
GroundComponent Component The collider component we're standing on. Null if we're standing nothing
GroundSurface Surface If we're stnding on a surface this is it
GroundFriction Single The friction property of the ground we're standing on.
GroundIsDynamic Boolean Are we standing on a surface that is physically dynamic
TimeSinceGrounded TimeSince Amount of time since this character was last on the ground
TimeSinceUngrounded TimeSince Amount of time since this character was last not on the ground
UseInputControls Boolean
WalkSpeed Single
RunSpeed Single
DuckedSpeed Single
JumpSpeed Single
DuckedHeight Single
AccelerationTime Single Amount of seconds it takes to get from your current speed to your requuested speed, if higher
DeaccelerationTime Single Amount of seconds it takes to get from your current speed to your requuested speed, if lower
AltMoveButton String The button that the player will press to use to run
RunByDefault Boolean If true then the player will run by default, and holding AltMoveButton will switch to walk
EnablePressing Boolean Allows to player to interact with things by "use"ing them. Usually by pressing the "use" button.
UseButton String The button that the player will press to use things
ReachLength Single How far from the eye can the player reach to use things
UseLookControls Boolean When true we'll move the camera around using the mouse
RotateWithGround Boolean
PitchClamp Single
LookSensitivity Single Allows modifying the eye angle sensitivity. Note that player preference sensitivity is already automatically applied, this is just extra.
CurrentHeight Single Gets the current character height from BodyHeight when standing, otherwise uses DuckedHeight when ducking.
Mode MoveMode
Hovered Component The object we're currently looking at
Pressed Component The object we're currently using by holding down USE
Tooltips List<Tooltip> The tooltip of the currently hovered Pressable object
StepDebug Boolean Enable debug overlays for this character

Methods

Void CreateBodyRenderer()
Void UpdateAnimation(SkinnedModelRenderer renderer)

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

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.

Void PlayFootstepSound(Vector3 worldPosition, Single volume, Int32 foot)

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

Void PreventGrounding(Single seconds)

Prevent being grounded for a number of seconds

Void OnJumped()
Void UpdateDucking(Boolean wantsDuck)

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

Void UpdateLookAt()

Called in Update when Using is enabled

Void StopPressing()

Stop pressing. Pressed will become null.

Void StartPressing(Component obj)

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

BBox BodyBox(Single scale = 1, Single heightScale = 1)

Return an aabb representing the body

SceneTraceResult TraceBody(Vector3 from, Vector3 to, Single scale = 1, Single heightScale = 1)

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

GameObject CreateRagdoll(String name = Ragdoll)

Create a ragdoll gameobject version of our render body.

Fields

Name Type Description
DebugFootsteps Boolean Draw debug overlay on footsteps
Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.PlayerController