class PlayerController : Component

robot_2Generated
code_blocksInput

Description

The PlayerController class in the Sandbox namespace is a sealed class that extends the Component class. It is designed to manage player movement and interactions within a game environment. This class provides a comprehensive set of properties and methods to control player animations, physics, input handling, and more.

Members

Properties

Member NameSummary
UseAnimatorControlsEnables or disables animator controls.
RendererThe body will usually be a child object with SkinnedModelRenderer.
ShowCreateBodyRendererIf true, shows the "create body" button.
RotationAngleLimitLimits the rotation angle.
RotationSpeedControls the speed of rotation.
EnableFootstepSoundsEnables or disables footstep sounds.
FootstepVolumeControls the volume of footstep sounds.
FootstepMixerHandles the audio mixing for footstep sounds.
AimStrengthEyesHow strongly to look in the eye direction with our eyes.
AimStrengthHeadHow strongly to turn in the eye direction with our head.
AimStrengthBodyHow strongly to turn in the eye direction with our body.
UseCameraControlsEnables or disables camera controls.
EyeDistanceFromTopDistance from the top of the head to the eye.
ThirdPersonEnables or disables third-person view.
HideBodyInFirstPersonHides the body in first-person view.
RotateWithGroundEnables rotation with the ground.
UseFovFromPreferencesUses field of view from preferences.
CameraOffsetOffset for the camera position.
ToggleCameraModeButtonButton to toggle camera mode.
BodyRepresents the player's physical body.
BodyColliderCollider for the player's body.
FeetColliderCollider for the player's feet.
ColliderObjectGameObject representing the collider.
BodyRadiusRadius of the player's body.
BodyHeightHeight of the player's body.
BodyMassMass of the player's body.
BodyCollisionTagsTags for body collision.
BrakePowerExtra friction applied when slowing down.
AirFrictionFriction applied when in the air.
ShowRigidbodyComponentShows the Rigidbody component.
ShowColliderComponentsShows the Collider components.
WishVelocityDesired velocity of the player.
IsOnGroundIndicates if the player is on the ground.
VelocityActual physical velocity minus ground velocity.
GroundVelocityVelocity of the ground underneath.
GroundYawYaw of the ground.
IsClimbingTrue when entering a climbing MoveMode.
IsSwimmingTrue when entering a swimming MoveMode.
EyeAnglesThe direction the player is looking.
EyePositionPlayer's eye position in first-person mode.
EyeTransformPlayer's eye position in first-person mode.
IsDuckingTrue if the player is ducking.
HeadroomDistance from the top of the head to the closest ceiling.
GroundObjectThe object the player is standing on.
GroundComponentThe collider component the player is standing on.
GroundSurfaceThe surface the player is standing on.
GroundFrictionFriction of the ground the player is standing on.
GroundIsDynamicTrue if standing on a dynamic surface.
TimeSinceGroundedTime since the player was last on the ground.
TimeSinceUngroundedTime since the player was last not on the ground.
UseInputControlsEnables or disables input controls.
WalkSpeedSpeed of walking.
RunSpeedSpeed of running.
DuckedSpeedSpeed when ducked.
JumpSpeedSpeed of jumping.
DuckedHeightHeight when ducked.
AccelerationTimeTime to accelerate to requested speed.
DeaccelerationTimeTime to deaccelerate to requested speed.
AltMoveButtonButton to press for running.
RunByDefaultIf true, player runs by default.
EnablePressingAllows interaction with objects by using them.
UseButtonButton to press to use things.
ReachLengthDistance the player can reach to use things.
UseLookControlsEnables camera movement with the mouse.
PitchClampClamp for the pitch angle.
LookSensitivityModifies eye angle sensitivity.
ModeCurrent movement mode.
HoveredThe object currently being looked at.
PressedThe object currently being used.
StepDebugEnables debug overlays for the character.

Methods

Member NameSummary
CreateBodyRendererCreates a body renderer for the player.
UpdateAnimationUpdates the animation for the renderer, including body rotation.
JumpAdds velocity for jumping, clamping to direction.
PlayFootstepSoundPlays a footstep sound at a given position and volume.
PreventGroundingPrevents grounding for a specified number of seconds.
OnJumpedCalled when the player jumps.
UpdateDuckingUpdates ducking state based on input.
UpdateLookAtUpdates the look-at direction when using is enabled.
StopPressingStops pressing, setting pressed to null.
StartPressingStarts pressing a target component.
BodyBoxReturns an AABB representing the body.
TraceBodyTraces the AABB body from one position to another.
CreateRagdollCreates a ragdoll GameObject version of the render body.

Fields

Member NameSummary
DebugFootstepsDraws debug overlay on footsteps.