- Qt 6.4
- Qt Quick 3D Physics
- QML Types
- CharacterController
- Qt Quick 3D Physics | Commercial or GPLv3

# CharacterController QML Type

Defines a character controller. More...

Import Statement: | import QtQuick3DPhysics
Since: | Qt 6.4
Inherits: | PhysicsBody

- List of all members, including inherited members

## Properties

- collisions : Collisions
- gravity : vector3d
- midAirControl : bool
- speed : vector3d

## Methods

- teleport(vector3d position)

## Detailed Description

The CharacterController type controls the motion of a character.

A character is an entity that moves under external control, but is still constrained by physical barriers and (optionally) subject to gravity. This is in contrast to dynamic rigid bodies which are either completely controlled by the physics simulation (for non-kinematic bodies); or move exactly where placed, regardless of barriers (for kinematic objects).

For a first-person view, the camera is typically placed inside a character controller.

## Property Documentation

[read-only] collisions : Collisions

This property holds the current collision state of the character. It is either `None` for no collision, or an OR combination of `Side`, `Up`, and `Down`:

Constant | Description
--- | ---
`CharacterController.None` | The character is not colliding with anything. If gravity is non-null, this means that the character is in free fall.
`CharacterController.Side` | The character is colliding with something from the side.
`CharacterController.Up` | The character is colliding with something from above.
`CharacterController.Down` | The character is colliding with something from below. In standard gravity, this means that the character is on the ground.

gravity : vector3d

This property defines the gravitational acceleration that applies to the character. For a character that walks on the ground, it should typically be set to DynamicsWorld.gravity. A floating character that has movement controls in three dimensions will normally have gravity `(0, 0, 0)`. The default value is `(0, 0, 0)`.

midAirControl : bool

This property defines whether the speed property has effect when the character is in free fall. This is only relevant if gravity in not null. A value of `true` means that the character will change direction in mid-air when speed changes. A value of `false` means that the character will continue on its current trajectory until it hits another object. The default value is `true`.

speed : vector3d

This property defines the controlled speed of the character. This is the speed the character would move in the absence of gravity and without interacting with other physics objects.

This property does not reflect the actual velocity of the character. If the character is stuck against terrain, the character can move slower than the defined `speed`. Conversely, if the character is in free fall, it may move much faster.

The default value is `(0, 0, 0)`.

## Method Documentation

teleport(vector3d position)

Immediately move the character to position without checking for collisions. The caller is responsible for avoiding overlap with static objects.