CharacterController QML Type

Controls the motion of a character. 更多...

import 语句: import QtQuick3D.Physics
Since: Qt 6.4
继承:

PhysicsBody

特性

信号

  • shapeHit (PhysicsNode * body , vector3D position , vector3D impulse , vector3D normal ) (从 6.6 起)

方法

详细描述

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).

To control the motion of a character controller, set movement to the desired velocity.

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

注意: collisionShapes must be set to a single CapsuleShape . No other shapes are supported.

注意: The character controller is able to scale obstacles that are lower than one fourth of the capsule shape's height.

另请参阅 Shapes and Bodies overview documentation .

特性文档编制

collisions : Collisions [read-only]

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

常量 描述
CharacterController.None The character is not touching anything. If gravity is non-null, this means that the character is in free fall.
CharacterController.Side The character is touching something on its side.
CharacterController.Up The character is touching something above it.
CharacterController.Down The character is touching something below it. In standard gravity, this means that the character is on the ground.

注意: The directions are defined relative to standard gravity: Up is always along the positive y-axis, regardless of the value of CharacterController.gravity or PhysicsWorld.gravity

enableShapeHitCallback : bool [since 6.6]

This property enables/disables the CharacterController::shapeHit callback for this character controller.

Default value: false

该特性在 Qt 6.6 引入。

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 PhysicsWorld.gravity . A floating character that has movement controls in three dimensions will normally have gravity (0, 0, 0) 。默认值为 (0, 0, 0) .

midAirControl : bool

This property defines whether the movement 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 movement 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 .

movement : vector3d

This property defines the controlled motion of the character. This is the velocity 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 speed defined by movement . Conversely, if the character is in free fall, it may move much faster.

默认值为 (0, 0, 0) .

信号文档编制

[since 6.6] shapeHit ( PhysicsNode * body , vector3D position , vector3D impulse , vector3D normal )

此信号发射当 movement has been called and it would result in a collision with a DynamicRigidBody StaticRigidBody and enableShapeHitCallback 被设为 true 。参数 body , position , impulse and normal contain the body, position, impulse force and normal for the contact point.

注意: 相应处理程序是 onShapeHit .

This signal was introduced in Qt 6.6.

方法文档编制

teleport ( vector3d position )

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