<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />
Navigation
</aside>
<aside> 💡 GameController in the Game scene runs the loop of one level: load the level, spawn the launcher, aim, launch, finish and reward.
</aside>
UIStartScreen, UILaunch, UIGame, UIRunResult, UILevelComplete and UIProgression.LevelSelectionController, then the Level Index field. An index outside the database falls back to the first level.LevelSetup.AimInputType is enabled and all the others are disabled.LevelSceneController is found in it and initialized with the level id. The launch ramp is spawned at the start point when the LevelSetup has one.ProgressionController.LoadLevel passes the upgrades of the Level Character to UpgradesController.Character.Prefab is instantiated.UIController initializes the pages and GameController subscribes to their events.PrepareRun runs once the level scene is ready and after every restart or reward.
CharacterState controls what the character does:
| State | Meaning |
|---|---|
| Idle | Standing at the start. |
| Aiming | The player sets the launch. |
| Launched | The run is active and steering is enabled. |
| Crashed | The vehicle hit an obstacle and the character is ejected. |
| Sinking | The character entered water. |
| Phase | Trigger | What GameController does |
|---|---|---|
| Aim | Tap on the start screen | character.BeginAim(), show UILaunch, camera state Aim. |
| Cancel | Back button of UILaunch |
Return to the start screen and the Start camera. |
| Launch | AimInput.OnAimReleased |
launcher.GetLaunchVelocity() goes to character.Launch, steering is enabled, show UIGame, camera state Run. |
| Crash | PlayerController.OnCrashed |
Disable steering, move the camera to the crash target. |
| Splash | PlayerController.OnSplashed |
Freeze the run camera, play water particles and the splash sound. |
| Run finished | PlayerController.OnRunFinished |
Calculate the reward, show the flag and the record, show UIRunResult after 0.75 seconds. |
| Level finished | PlayerController.OnFinishReached |
Confetti, freeze the camera, show UILevelComplete after 2.5 seconds. |
PrepareRun and the start screen plays the coin cloud animation.Awake loads that level. The next level is the following one in the Levels Database. After the last level the first one is loaded.CameraController switches between four Cinemachine virtual cameras of the Game scene:
| State | When |
|---|---|
| Start | Start screen. |
| Aim | Aim phase. |
| Run | Launched run. |
| UpgradeFocus | Focus on the vehicle while an upgrade is shown. |
The blend between states is defined in the Camera Blends asset in Assets/Project Files/Data. The switch from Run to Start is a cut, so the camera returns to the start point behind the fade overlay.
Subscribe to the events of PlayerController, or to the events of the page that you need. Do not edit the flow inside GameController when only a reaction is needed.
character.OnRunFinished += OnRunFinished;
character.OnCrashed += OnCrashed;
Always unsubscribe in OnDestroy, as GameController does.