<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />
Navigation
</aside>
<aside> 💡 PlayerController is the state machine of the character. It owns the rigidbody, the ground check, the run end detection and the effects. The vehicle behavior is a separate object, so it can be swapped during the run.
</aside>
TouchMoveInput implements it.The Character prefab has the PlayerController on the root with a Rigidbody. These fields link the visual parts:
| Field | Description |
|---|---|
| Default Vehicle | The VehicleData used at the start of every run. |
| Visual Anchor | Parent of the vehicle and character visuals. |
| Default Visual Root | The vehicle visual that the VehicleEfficiency upgrade stages replace. |
| Character Visual | The rider model, for example the bear. It is placed on the Seat of the active vehicle visual. |
| Character Animation | CharacterAnimationBehavior of the rider. |
| Rope Point | Where the slingshot rope wraps the character. |
| Eject | CharacterEjectBehavior. Leave empty for a character that is never thrown out. |
| Body Collider | Box collider for a vehicle on real rigidbody physics, for example the car. |
| Effect Flash Renderer, Effect Flash Color | Material flash when a booster is activated. |
| Upgrade Focus Padding | Multiplier of the camera padding when the upgrade is shown. Use a value above 1 for small vehicles. |
Optional components that react to the run: TerrainTrackBehavior, GroundDustBehavior, SurfaceAudioController, BoosterVisualBehavior. See Vehicle Visuals & Surface Effects.
| State | Description |
|---|---|
| Idle | At the start. ResetToStart sets it. |
| Aiming | BeginAim. The body is kinematic and moves with the slingshot pull. |
| Launched | Launch(velocity) unlocks the body and sets the velocity. Steering is active. |
| Crashed | The sled hit an obstacle and the character is ejected. |
| Sinking | The character entered water. |
| Cause | What happens |
|---|---|
| Stop | The speed stays below Stop Speed Threshold after Stop Check Delay. Rolling back toward the start also counts as a stop. |
| Crash | Crash(collider). The character is ejected. The run finishes after the wave animation. |
| Water | EnterWater(water). The run finishes after the Finish Delay of the water. |
| Fail | Fail(). Used by obstacles that the vehicle cannot clear, for example Chasm. |
| Finish wall | ReachFinish(point). The character keeps driving and GameController completes the level. |
The run distance is measured along the launch direction from the launch position to RunEndPosition.
| Event | When |
|---|---|
OnRunFinished |
The run ended. |
OnCrashed |
The character was ejected. |
OnSplashed(position) |
The character entered water. |
OnFinishReached(point) |
The finish wall was crossed. |
OnVisualChanged |
The vehicle visual changed, for example after an upgrade. |
The character cannot turn back to the start. Steering away from the course fades out between Course Soft Angle and Course Max Angle. Moving past the soft angle bleeds speed, up to Course Brake at the max angle.
World objects and boosters call these methods. They have no effect while the body is kinematic.
| Method | Use |
|---|---|
AddSpeed(amount) |
Adds speed along the flight direction. |
StartRocket(speed), StopRocket() |
Holds a target speed. |
ApplyKnockback(multiplier), BreakThrough(multiplier) |
Speed change after hitting a breakable object. |
SetIronSkinActive(bool) |
Iron skin booster state. |
SwapVehicle(VehicleData), RevertVehicle() |
Temporary vehicle swap. |
SetPermanentVisual(prefab) |
Applies the vehicle visual of an upgrade stage. |
The ground check exposes IsGrounded, GroundCollider, GroundPoint, GroundNormal, GroundSurfaceMaterial and HeightAboveGround. The surface effects and the movement behaviors use them.
PlayerController.Instance is the static reference of the current character.