A component for kinematic character controller prototyping that uses a circle as a shape. You can quickly add this to an entity and set a CharacterController2DConfig, then call the CharacterController2D.Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?) method in a system update.
More...
|
PhysicsQueryRef | AddBroadPhaseQuery (FrameBase frame, EntityRef entity, int? layerMask=null) |
| Adds a Broad-phase query to the 2D Physics scene, according to the KCC config settings, and store the query ref in BroadPhaseQuery. This ref will be used on the next time Move or ComputeRawMovement is called to retrieve the resolved query results and perform the KCC logic. More...
|
|
void | Init (FrameBase frame, CharacterController2DConfig config=null) |
| Initializes the 2D character controller component. More...
|
|
void | Init (FrameThreadSafe frame, CharacterController2DConfig config=null) |
|
void | Jump (FrameBase frame, bool ignoreGrounded=false, FP? impulse=null) |
| Applies a vertical impulse to the KCC velocity. More...
|
|
void | Jump (FrameThreadSafe frame, bool ignoreGrounded=false, FP? impulse=null) |
|
void | Move (FrameBase frame, EntityRef entity, FPVector2 direction, IKCCCallbacks2D callback=null, int? layerMask=null, Boolean? useManifoldNormal=null, FP? deltaTime=null) |
| Queries the 2D physics scene with CharacterController2D.ComputeRawMovement(FrameBase, EntityRef, Transform2D*, CharacterController2D*, FPVector2, IKCCCallbacks2D, int?, bool?, FP, FP), computes a default steering in the desired direction and moves the entity . More...
|
|
void | Move (FrameThreadSafe frame, EntityRef entity, FPVector2 direction, IKCCCallbacks2D callback=null, int? layerMask=null, Boolean? useManifoldNormal=null, FP? deltaTime=null) |
|
void | SetConfig (FrameBase frame, CharacterController2DConfig config=null) |
| Sets or changes this KCC's config. More...
|
|
void | SetConfig (FrameThreadSafe frame, CharacterController2DConfig config=null) |
|
|
static CharacterController2DMovement | ComputeRawMovement (FrameBase frame, EntityRef entity, Transform2D *transform, CharacterController2D *kcc, FPVector2 direction, IKCCCallbacks2D callback=null, int? layerMask=null, bool? useManifoldNormal=null, FP verticalPosition=default, FP verticalHeight=default) |
| Queries the 2D physics scene in the transform position, using the kcc config, and computes movement data. The movement data can be used to apply a custom steering to the character based on its surrounding environment. For using the default steering, use Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?). More...
|
|
static CharacterController2DMovement | ComputeRawMovement (FrameBase frame, EntityRef entity, Transform2D *transform, Transform2DVertical *tVertical, CharacterController2D *kcc, FPVector2 direction, IKCCCallbacks2D callback=null, int? layerMask=null, bool? useManifoldNormal=null) |
| Queries the 2D physics scene in the transform position, using the kcc config, and computes movement data. The movement data can be used to apply a custom steering to the character based on its surrounding environment. For using the default steering, use Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?). More...
|
|
static CharacterController2DMovement | ComputeRawMovement (FrameThreadSafe frame, EntityRef entity, Transform2D *transform, CharacterController2D *kcc, FPVector2 direction, IKCCCallbacks2D callback=null, int? layerMask=null, bool? useManifoldNormal=null, FP verticalPosition=default, FP verticalHeight=default) |
|
static CharacterController2DMovement | ComputeRawMovement (FrameThreadSafe frame, EntityRef entity, Transform2D *transform, Transform2DVertical *tVertical, CharacterController2D *kcc, FPVector2 direction, IKCCCallbacks2D callback=null, int? layerMask=null, bool? useManifoldNormal=null) |
|
static void | Serialize (void *p, FrameSerializer serializer) |
| Serializes a CharacterController2D into a FrameSerializer. More...
|
|
|
PhysicsQueryRef | BroadPhaseQuery |
| Broad-Phase Query index of the last query added by calling AddBroadPhaseQuery. To use Broad-Phase queries, call AddBroadPhaseQuery before the Physics system Update runs. When Move() is called and a broad-phase query has been added, the method will not perform a new query, but retrieve and use the results of the broad-phase query previously injected. More...
|
|
FP | MaxSpeed |
| The character's maximum horizontal speed will be clamped by this value. More...
|
|
FPVector2 | Velocity |
| The current accumulated velocity of the character controller. More...
|
|
|
const int | SIZE = sizeof(long) + PhysicsQueryRef.SIZE + AssetRef<CharacterController2DConfig>.SIZE + FP.SIZE + FPVector2.SIZE |
| The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed. More...
|
|
A component for kinematic character controller prototyping that uses a circle as a shape. You can quickly add this to an entity and set a CharacterController2DConfig, then call the CharacterController2D.Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?) method in a system update.
◆ Init()
Initializes the 2D character controller component.
Use SetConfig instead in order to set or change the KCC config without resetting other fields. This method is not thread-safe: use the thread-safe overload if calling from a multi-threaded context.
- Parameters
-
◆ SetConfig()
Sets or changes this KCC's config.
This method does not reset other values like Grounded and Velocity: use Init for that. This method is not thread-safe: use the thread-safe overload if calling from a threaded context.
- Parameters
-
◆ Jump()
void Quantum.CharacterController2D.Jump |
( |
FrameBase |
frame, |
|
|
bool |
ignoreGrounded = false , |
|
|
FP? |
impulse = null |
|
) |
| |
|
inline |
Applies a vertical impulse to the KCC velocity.
This method is not thread-safe. Use the thread-safe overload if calling from a threaded context.
No steering is performed at this stage. To actually move the character, use Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?).
- Parameters
-
◆ AddBroadPhaseQuery()
PhysicsQueryRef Quantum.CharacterController2D.AddBroadPhaseQuery |
( |
FrameBase |
frame, |
|
|
EntityRef |
entity, |
|
|
int? |
layerMask = null |
|
) |
| |
|
inline |
Adds a Broad-phase query to the 2D Physics scene, according to the KCC config settings, and store the query ref in BroadPhaseQuery. This ref will be used on the next time Move or ComputeRawMovement is called to retrieve the resolved query results and perform the KCC logic.
The added BP-Query must be retrieve on the same frame. To cancel the addition of a BP-Query and perform a regular one when moving the KCC, set BroadPhaseQuery to default.
- Parameters
-
frame | The current frame object. |
entity | The entity that represents the character. It must have a Transform2D component, which will be used to compute the query position, along with a Transform2DVertical (optional), if the entity has one. |
layerMask | A mask that specifies which layers should be considered by the query. If null (default), the layer maks defined in the KCC config will be used. |
- Returns
- The index of the added query.
◆ Move()
Queries the 2D physics scene with CharacterController2D.ComputeRawMovement(FrameBase, EntityRef, Transform2D*, CharacterController2D*, FPVector2, IKCCCallbacks2D, int?, bool?, FP, FP), computes a default steering in the desired direction and moves the entity .
This method is not thread-safe. Use the thread-safe overload if calling from a threaded context.
The entity must have a Transform2D component.
- Parameters
-
frame | The frame in which the entity is being moved. |
entity | The entity that represents the character. Any collider attached by this entity is ignored in the raw movement computation. |
direction | The intended movement direction. |
callback | An object that can receive the KCC callbacks. If calling from a system that implements the interface, you can use the "this" keyword. |
layerMask | A mask that specifies which layers will be checked against in the raw movement computation. If null is passed, the layer maks defined in the KCC config will be used. To create a layer mask, see LayerInfo.GetLayerMask(string) and overloads on the frame.Layers property. |
useManifoldNormal | If the hit manifold normal should be used when computing the raw movement. If false , the normal is computed from the query position and the contact point. If no value is provided, the CharacterController2DConfig.UseManifoldNormal of the KCC config is used. |
deltaTime | The delta timed used to integrate the kcc velocity. If no value is provided, the frame delta time is used. |
◆ Serialize()
static void Quantum.CharacterController2D.Serialize |
( |
void * |
p, |
|
|
FrameSerializer |
serializer |
|
) |
| |
|
inlinestatic |
◆ ComputeRawMovement() [1/2]
Queries the 2D physics scene in the transform position, using the kcc config, and computes movement data. The movement data can be used to apply a custom steering to the character based on its surrounding environment. For using the default steering, use Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?).
This method is not thread-safe. Use the thread-safe overload if calling from a threaded context.
- Parameters
-
frame | The frame in which the physics scene is being queried. |
entity | The entity that represents the character. Any collider attached by this entity is ignored in the raw movement computation. |
transform | A pointer to a Transform2D component that has the position where the scene will be queried at, usually being the entity transform. |
kcc | A pointer to a CharacterController2D component that has the config used by the query, usually being the entity kcc component. |
direction | The intended movement direction. |
callback | An object that can receive the KCC callbacks. |
If calling from a system that implements the interface, you can use the "this" keyword.
- Parameters
-
layerMask | A mask that specifies which layers will be checked against in the raw movement computation. If null is passed, the layer mask defined in the KCC config will be used. To create a layer mask, see LayerInfo.GetLayerMask(string) and overloads on the frame.Layers property. |
useManifoldNormal | If the hit manifold normal should be used when computing the raw movement. If false , the normal is computed from the query position and the contact point. If no value is provided, the CharacterController2DConfig.UseManifoldNormal of the KCC config is used. |
verticalPosition | The 2.5D vertical position where the 2D KCC query will be performed. |
verticalHeight | The 2.5D vertical height with which the 2D KCC query will be performed. |
- Returns
- A CharacterController2DMovement struct with raw movement data that can be used to compute a custom steering.
◆ ComputeRawMovement() [2/2]
Queries the 2D physics scene in the transform position, using the kcc config, and computes movement data. The movement data can be used to apply a custom steering to the character based on its surrounding environment. For using the default steering, use Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?).
- Parameters
-
frame | The frame in which the physics scene is being queried. |
entity | The entity that represents the character. Any collider attached by this entity is ignored in the raw movement computation. |
transform | A pointer to a Transform2D component that has the position where the scene will be queried at, usually being the entity transform. |
tVertical | A pointer to a Transform2DVertical that has the position where the scene will be queried at, usually being the entity transform. |
kcc | A pointer to a CharacterController2D component that has the config used by the query, usually being the entity kcc component. |
direction | The intended movement direction. |
callback | An object that can receive the KCC callbacks. |
layerMask | >A mask that specifies which layers will be checked against in the raw movement computation. If null is passed, the layer mask defined in the KCC config will be used. To create a layer mask, see LayerInfo.GetLayerMask(string) and overloads on the frame.Layers property. |
useManifoldNormal | If the hit manifold normal should be used when computing the raw movement. If false , the normal is computed from the query position and the contact point. If no value is provided, the CharacterController2DConfig.UseManifoldNormal of the KCC config is used. |
- Returns
- A CharacterController2DMovement struct with raw movement data that can be used to compute a custom steering.
◆ SIZE
The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.
◆ BroadPhaseQuery
PhysicsQueryRef Quantum.CharacterController2D.BroadPhaseQuery |
Broad-Phase Query index of the last query added by calling AddBroadPhaseQuery. To use Broad-Phase queries, call AddBroadPhaseQuery before the Physics system Update runs. When Move() is called and a broad-phase query has been added, the method will not perform a new query, but retrieve and use the results of the broad-phase query previously injected.
◆ MaxSpeed
FP Quantum.CharacterController2D.MaxSpeed |
The character's maximum horizontal speed will be clamped by this value.
◆ Velocity
FPVector2 Quantum.CharacterController2D.Velocity |
The current accumulated velocity of the character controller.
◆ Config
◆ Grounded
Boolean? Quantum.CharacterController2D.Grounded |
|
getset |
Returns true if the character controller is touching the floor.
◆ Jumped
Boolean? Quantum.CharacterController2D.Jumped |
|
getset |
If the character jumped this frame. See Jump(FrameBase, bool, FP?).
This state is consumed in the default steering method Move(FrameBase, EntityRef, FPVector2, IKCCCallbacks2D, int?, bool?, FP?).
◆ BroadPhaseQueryIndex
int Quantum.CharacterController2D.BroadPhaseQueryIndex |
|
get |