πŸ”ΉExample Controller

This page explains the example character controller

Overview

Character Example Controller handles player movement and input actions, such as:

  • Crouch, Sprint and Jump

  • Look and leaning

  • Items equip, use and unequip

  • Climbing and vaulting

To function properly, it requires Character Controller and Player Input components:

Character Controller and Player Inputs.

Update Flow

When the game starts, the example controller will try to find CasProp components in the hierarchy β€” items like torch, axe or barrel β€” and equip the first found item. It supposses that items are added directly to the character (for example, parented to the right hand).

On Update(), it processes character speed, rotation and movement based on the input values.

This component receives messages from the Player Input to implement custom actions:

  • OnInteract() β€” tries to start an interaction.

  • OnSprint() β€” tries to start sprinting.

  • OnCrouch() β€” toggles current crouching state.

  • OnLook(InputValue value) β€” accumulates delta look values.

  • OnJump() β€” tries to jump.

  • OnMove(InputValue value) β€” updates player Vector2 input direction.

  • OnAim(InputValue value) β€” updates camera and active item aiming status.

  • OnTogglePerspective() β€” toggles first- and third-person views.

  • OnChangeShoulder() β€” toggles between right and left shoulder views.

  • OnLean(InputValue value) β€” updates current leaning angle.

Properties

Controller

Character Example Controller.
  • Time Scale β€” active time scale value.

  • Mouse Sensitivity β€” look input sensitivity multiplier.

Standing

Standing movement properties.

  • Acceleration β€” how fast player should accelerate.

  • Deceleration β€” how fast player should decelerate.

  • Walk Speed β€” normal speed when walking.

  • Sprint Speed β€” normal speed when sprinting.

Crouching

  • Crouch Walk Speed β€” walking speed when crouched.

In Air

In air parameters.

  • Jump Height β€” how far should the character jump.

  • Fall Delay β€” time ungrounded before entering the in air state.

  • Gravity β€” how strong is the force pulling player back to the ground.

  • Max Fall Velocity β€” this will clamp max fall speed.

View

Perspective and rotation mode.

  • Is First Person β€” controls active perspective.

  • Orient Rotation To Movement β€” aligns rotation with the movement vector. This feature only in third-person mode.

Animation

  • Lean Angle β€” max leaning angle.

Steps

Procedural steps played to avoid feet sliding.

  • Steps Crouch/Uncrouch β€” played when player is crouching or uncrouching.

  • Step In Place β€” played when player is changing items.

  • Start/Stop Moving β€” played during movement transitions.

Smoothing

Animation smoothing based on the target velocity (acceleration, deceleration).

  • Animator Standing β€” applied when standing.

  • Animator Crouching β€” applied when crouching.

Last updated