Characters and the player
Skill ferret-character · download all skills · SKILL.md
When to use#
A walking player or NPC body, jump and slope tuning, camera modes.
The model#
spawnCharacter(world, id, position) returns an entity with CharacterMovement: a capsule moving against static geometry, with walk, run, crouch, jump, steps, slopes, acceleration. CharacterParams follow UE's Character Movement Component, in metres and seconds. PlayerController turns input actions into movement and camera, reading the action names you give (PlayerActions) and ignoring the ones you leave out. CameraRig is first or third person, switchable at run time, with spring-arm collision.
Steps#
spawnCharacter, thenentity.add(PlayerController, { camera: { view: 'first' } }).- Tune with
CharacterParams, or per level through the manifest'smovementblock. - Hook events:
character:jump,character:land. - Level movement values override Ferret's defaults for that level only.
On all the cores#
With many characters the step of each (its sweeps and rays against the static geometry) goes to the workers: they hold a copy of the collidable meshes (PhysicsService.collisionCopy) and CharacterBatch.of(world) sends the characters in pieces. It stays in the game's thread for a few characters, while a collidable mesh keeps moving, for a character in water or mud and for one that is crouching or standing; CharacterBatch.of(world).reason says which. A result is put back after every component of the step has had its turn, so a component after the character sees the new place at the next step. Moving the character by hand (teleport, shift, setFlying) drops a result that is on its way.
Check afterwards#
Walk a slope, a step and a gap in a grey-box level; land and jump events fire; the camera does not clip through walls.
What usually goes wrong#
- Solid meshes not marked
checkCollisions(or notcollidein the manifest): the capsule falls through. - Gravity changed by the physics gravity capability: the character reads the field only while it is on (see
ferret-physics-gravity-media). - Unit mistakes: values are metres and seconds, not centimetres as in the UE editor.
Files#
reference/packages.md— Characters, animation graphs, NPC navigation, interactables, zones and transformations.reference/api-character.md— every export of@ferret/characterwith signature and doc comment