class PlayerController : Component

book_4_sparkGenerated
code_blocksInput

Description

The PlayerController class in the Sandbox namespace is a component that manages player movement, animation, and interaction within a game scene. It provides a comprehensive set of properties and methods to control player behavior, including movement speed, jumping, ducking, and interaction with game objects.

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 footstep sounds.
FootstepVolumeControls the volume of footstep sounds.
FootstepMixerHandles the audio mixing for footstep sounds.
AimStrengthEyesDetermines how strongly to look in the eye direction with eyes.
AimStrengthHeadDetermines how strongly to turn in the eye direction with the head.
AimStrengthBodyDetermines how strongly to turn in the eye direction with the body.
UseCameraControlsEnables or disables camera controls.
EyeDistanceFromTopDistance from the top of the head to the eye position.
ThirdPersonEnables 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.
BodyColliderThe collider for the player's body.
FeetColliderThe collider for the player's feet.
ColliderObjectThe game object 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.
WishVelocityThe desired velocity of the player.
IsOnGroundIndicates if the player is on the ground.
VelocityActual physical velocity minus ground velocity.
GroundVelocityVelocity of the ground underneath the player.
GroundYawYaw of the ground.
IsClimbingTrue when entering a climbing mode.
IsSwimmingTrue when entering a swimming mode.
EyeAnglesThe direction the player is looking.
EyePositionThe player's eye position in first-person mode.
EyeTransformThe player's eye transform 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 the ground is physically dynamic.
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 the requested speed.
DeaccelerationTimeTime to deaccelerate to the requested speed.
AltMoveButtonButton to switch between running and walking.
RunByDefaultTrue if the player runs by default.
EnablePressingAllows interaction with objects by using them.
UseButtonButton to use objects.
ReachLengthDistance the player can reach to use objects.
UseLookControlsEnables camera movement with the mouse.
PitchClampClamp for the pitch angle.
LookSensitivityModifies the eye angle sensitivity.
ModeCurrent movement mode of the player.
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, adjusting for current velocity.
PlayFootstepSoundPlays a footstep sound at a given position and volume.
PreventGroundingPrevents grounding for a specified number of seconds.
OnJumpedCalled when the player jumps.
UpdateDuckingUpdates the 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.