First Person Controller API
advanced scriptingVoxel Play 3 · Scripting / API
Overview
Properties and methods accessible through VoxelPlayFirstPersonController.instance.
Properties
bool crosshairOnBlock- Whether the crosshair currently targets an accessible voxel (determined by the hit range in the Player component)VoxelHitInfo crosshairHitInfo- Provides information about the voxel under the crosshairbool isFlying- Player is flyingbool isMoving- Player is moving (walk or run)bool isRunning- Player is runningbool isInWater- Player is in water (surface or underwater)bool isSwimming- Player is on water surfacebool isUnderwater- Player is below water surfacebool isGrounded- Player is on groundbool isCrouched- Player is crouchedbool isUnderground- Player is underground or undercoverVoxelDefinition voxelUnder- Voxel under the character feetbool cameraOrbitMode- Camera orbit mode statefloat cameraOrbitModeSpeed- Speed of orbit mode (default 4)float cameraOrbitModeDistanceV- Vertical distance in orbit mode (default 40)float cameraOrbitModeDistanceH- Horizontal distance in orbit mode (default 35)
Movement Settings
float walkSpeed- Walk speed (default 5)float runSpeed- Run speed (default 10)float flySpeed- Fly speed (default 20)float swimSpeed- Swim speed (default 3.7)float jumpSpeed- Jump speed (default 10)bool canClimb- Whether the player can climb (default true)float climbMaxStepHeight- Max step height for climbing (default 1.1)
Methods
SetCameraOrbitMode(bool state)- Transitions between free camera movement and orbit mode, enabling the camera to rotate around a target position. The demo scene "Colorizer" demonstrates this feature.AddExternalForce(Vector3 force)- Add a temporary push force to the characterMoveTo(Vector3 newPosition)- Move the character to a specific positionMove(Vector3 deltaPosition)- Move the character by a delta positionSetFreeCamMode(bool enableFreeCam)- Enable/disable free camera modeResetCrosshairPosition()- Reset crosshair to default positionForceUpdateCrosshair(int frames = 2)- Force crosshair update for N framesToggleCharacterController(bool state)- Enable/disable the CharacterController componentToggleCharacterLight()- Toggle character light on/offToggleCharacterLight(bool state)- Set character light stateSetFootstepSounds(AudioClip[] footStepsSounds, AudioClip jumpSound, AudioClip landSound)- Set custom footstep sounds
Events
OnVoxelEnter- Triggered when player enters a voxel if that voxel definition hastriggerEnterEvent = trueOnVoxelWalk- Triggered when a player walks over a voxel if that voxel definition hastriggerWalkEvent = true
Was this page helpful?
Suggest an improvement
Help us improve this documentation page.