# Getting started with the CMC ## A C++ character Make the character's movement component a `UTRCCharacterMovementComponent`, the usual way: ```cpp AMyCharacter::AMyCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass<UTRCCharacterMovementComponent>(ACharacter::CharacterMovementComponentName)) { } ``` Or derive from `ATRCCharacter`, which does exactly that. ## Reparenting a Blueprint character A Blueprint character whose parent is **Character** can be moved over in one step: right click it in the Content Browser, **Set Up for Traversecraft**, and save. It reparents the Blueprint to **TRCCharacter** and compiles it; a window lists what changed. By hand it is the same thing: open it, **Class Settings > Parent Class**, and pick **TRCCharacter**. The movement component keeps its name and is a subclass of the CMC, so every node that used it still works. The Game Animation Sample's `SandboxCharacter_CMC` compiles with no errors after this. ## That is all Jump in front of a low wall, a ledge or a ladder. The component's **Traversal** section has every setting; see [Settings](../settings/). To play animations, see [Animation](../animation/). ## From code or Blueprint | Function | What it does | |---|---| | `TryTraverse()` | Starts a traversal or grabs a ladder on the next move, if one is in front. For a separate key instead of jump | | `GetTraversal()` | What the character is doing now: None, Vault, Mantle, Climb, Ladder, Hang, Slide, WallRun and the rest. The same on every machine | | `IsTraversing()` | Any of them | | `GetLadderClimbRate()` | On a ladder, -1 (down at full speed) to 1 (up at full speed) | | `FindTraversal(Plan)` | Looks without doing anything: what kind, the path and how long | | **Find Ladder** | The ladder in front that a jump would grab, if any | | `OnTraversalStarted`, `OnTraversalFinished` | Events with the kind, on every machine, including the ones that only watch | Set **Traverse On Jump** off to use only `TryTraverse`. Every call is listed in [Blueprint reference](../blueprint/). ## First person A first-person character usually turns its body to the camera every frame (**Use Controller Rotation Yaw**). During a traversal `ATRCCharacter` skips that, so a character hanging from a ledge keeps facing the wall while the player looks around, and a drop down to a ledge turns the body, not the view. Attach the camera to the head with **Use Pawn Control Rotation** on and the view never spins. The example map switches to first person with V. A C++ character of your own that does not derive from `ATRCCharacter` needs the same few lines: override `FaceRotation` and return early while `IsTraversing()`. It runs on the owner and in the server's copy of each move, so both skip it alike. ## Your own CMC subclass If your project already has a CMC subclass, derive it from `UTRCCharacterMovementComponent` instead of `UCharacterMovementComponent`. Traversecraft uses the compressed flag `FLAG_Custom_2` for `TryTraverse`. If you have your own saved move, derive it from `FTRCSavedMove` and your prediction data from `FTRCNetworkPredictionData`, and call the parent in `Clear`, `GetCompressedFlags`, `CanCombineWith`, `SetMoveFor` and `PrepMoveFor`. The moves use one custom movement mode per kind, from 100 up by default (the list is under **Traversal Custom Mode** in [Settings](../settings/)). If your game uses those numbers, change **Traversal Custom Mode**.