Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/GameFramework
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UActorComponent
- UMovementComponent
- UInterpToMovementComponent
- UNavMovementComponent
- UPawnMovementComponent
- UChaosVehicleMovementComponent
- UChaosWheeledVehicleMovementComponent
- UCharacterMovementComponent
- UArchVisCharMovementComponent
- UFloatingPawnMovement
- USpectatorPawnMovement
- UVirtualCameraMovementComponent
- UProjectileMovementComponent
- URotatingMovementComponent
References
| Module | Engine |
| Header | /Engine/Source/Runtime/Engine/Classes/GameFramework/MovementComponent.h |
| Include | #include "GameFramework/MovementComponent.h" |
Syntax
class UMovementComponent : public UActorComponent
Remarks
MovementComponent is an abstract component class that defines functionality for moving a PrimitiveComponent (our UpdatedComponent) each tick. Base functionality includes:
- Restricting movement to a plane or axis.
- Utility functions for special handling of collision results (SlideAlongSurface(), ComputeSlideVector(), TwoWallAdjust()).
- Utility functions for moving when there may be initial penetration (SafeMoveUpdatedComponent(), ResolvePenetration()).
- Automatically registering the component tick and finding a component to move on the owning Actor. Normally the root component of the owning actor is moved, however another component may be selected (see SetUpdatedComponent()). During swept (non-teleporting) movement only collision of UpdatedComponent is considered, attached components will teleport to the end location ignoring collision.
Variables
| Type | Name | Description | |
|---|---|---|---|
| uint8: 1 | bAutoRegisterPhysicsVolumeUpdates | If true, then applies the value of bComponentShouldUpdatePhysicsVolume to the UpdatedComponent. | |
| uint8: 1 | bAutoRegisterUpdatedComponent | If true, registers the owner's Root component as the UpdatedComponent if there is not one currently assigned. | |
| uint8: 1 | bAutoUpdateTickRegistration | If true, whenever the updated component is changed, this component will enable or disable its tick dependent on whether it has something to update. | |
| uint8: 1 | bComponentShouldUpdatePhysicsVolume | If true, enables bShouldUpdatePhysicsVolume on the UpdatedComponent during initialization from SetUpdatedComponent(), otherwise disables such updates. | |
| uint8: 1 | bConstrainToPlane | If true, movement will be constrained to a plane. | |
| uint8: 1 | bSnapToPlaneAtStart | If true and plane constraints are enabled, then the updated component will be snapped to the plane when first attached. | |
| uint8: 1 | bTickBeforeOwner | If true, after registration we will add a tick dependency to tick before our owner (if we can both tick). | |
| uint8: 1 | bUpdateOnlyIfRendered | If true, skips TickComponent() if UpdatedComponent was not recently rendered. | |
| EMoveComponentFlags | MoveComponentFlags | Flags that control the behavior of calls to MoveComponent() on our UpdatedComponent. | |
| FVector | PlaneConstraintNormal | The normal or axis of the plane that constrains movement, if bConstrainToPlane is enabled. | |
| FVector | PlaneConstraintOrigin | The origin of the plane that constrains movement, if plane constraint is enabled. | |
| TObjectPtr< USceneComponent > | UpdatedComponent | The component we move and update. | |
| TObjectPtr< UPrimitiveComponent > | UpdatedPrimitive | UpdatedComponent, cast as a UPrimitiveComponent. | |
| FVector | Velocity | Current velocity of updated component. |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UMovementComponent
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddRadialForce
(
const FVector& Origin, |
Adds force from radial force components. | |
| void | AddRadialImpulse
(
const FVector& Origin, |
Adds impulse from radial force components. | |
| FVector | ComputeSlideVector
(
const FVector& Delta, |
Compute a vector to slide along a surface, given an attempted move, time, and normal. | |
| FVector | ConstrainDirectionToPlane
(
FVector Direction |
Constrain a direction vector to the plane constraint, if enabled. | |
| FVector | ConstrainLocationToPlane
(
FVector Location |
Constrain a position vector to the plane constraint, if enabled. | |
| FVector | ConstrainNormalToPlane
(
FVector Normal |
Constrain a normal vector (of unit length) to the plane constraint, if enabled. | |
| float | GetGravityZ () |
Returns gravity that affects this component | |
| float | GetMaxSpeed () |
Returns maximum speed of component in current movement mode. | |
| FVector | GetPenetrationAdjustment
(
const FHitResult& Hit |
Calculate a movement adjustment to try to move out of a penetration from a failed move. | |
| APhysicsVolume * | Returns the PhysicsVolume this MovementComponent is using, or the world's default physics volume if none. | ||
| EPlaneConstraintAxisSetting | Get the plane constraint axis setting. | ||
| const FVector & | Returns the normal of the plane that constrains movement, enforced if the plane constraint is enabled. | ||
| FVector | GetPlaneConstraintNormalFromAxisSetting
(
EPlaneConstraintAxisSetting AxisSetting |
Helper to compute the plane constraint axis from the current setting. | |
| const FVector & | Get the plane constraint origin. | ||
| void | HandleImpact
(
const FHitResult& Hit, |
Called for Blocking impact | |
| void | InitCollisionParams
(
FCollisionQueryParams& OutParams, |
Initialize collision params appropriately based on our collision settings. | |
| bool | IsExceedingMaxSpeed
(
float MaxSpeed |
Returns true if the current velocity is exceeding the given max speed (usually the result of GetMaxSpeed()), within a small error tolerance. | |
| bool | IsInWater () |
Returns true if it's in PhysicsVolume with water flag | |
| bool | K2_MoveUpdatedComponent
(
FVector Delta, |
Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation. | |
| bool | MoveUpdatedComponent
(
const FVector& Delta, |
Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation. | |
| bool | MoveUpdatedComponent
(
const FVector& Delta, |
Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation. | |
| bool | MoveUpdatedComponentImpl
(
const FVector& Delta, |
||
| void | OnTeleported () |
Called by owning Actor upon successful teleport from AActor::TeleportTo(). | |
| bool | OverlapTest
(
const FVector& Location, |
Return true if the given collision shape overlaps other geometry at the given location and rotation. | |
| void | |||
| void | PhysicsVolumeChanged
(
APhysicsVolume* NewVolume |
Delegate when PhysicsVolume of UpdatedComponent has been changed | |
| bool | ResolvePenetration
(
const FVector& Adjustment, |
||
| bool | ResolvePenetration
(
const FVector& Adjustment, |
Try to move out of penetration in an object after a failed move. | |
| bool | ResolvePenetrationImpl
(
const FVector& Adjustment, |
||
| bool | SafeMoveUpdatedComponent
(
const FVector& Delta, |
Calls MoveUpdatedComponent(), handling initial penetrations by calling ResolvePenetration(). | |
| bool | SafeMoveUpdatedComponent
(
const FVector& Delta, |
Calls MoveUpdatedComponent(), handling initial penetrations by calling ResolvePenetration(). | |
| void | SetPlaneConstraintAxisSetting
(
EPlaneConstraintAxisSetting NewAxisSetting |
Set the plane constraint axis setting. | |
| void | SetPlaneConstraintEnabled
(
bool bEnabled |
Sets whether or not the plane constraint is enabled. | |
| void | SetPlaneConstraintFromVectors
(
FVector Forward, |
Uses the Forward and Up vectors to compute the plane that constrains movement, enforced if the plane constraint is enabled. | |
| void | SetPlaneConstraintNormal
(
FVector PlaneNormal |
Sets the normal of the plane that constrains movement, enforced if the plane constraint is enabled. | |
| void | SetPlaneConstraintOrigin
(
FVector PlaneOrigin |
Sets the origin of the plane that constrains movement, enforced if the plane constraint is enabled. | |
| void | SetUpdatedComponent
(
USceneComponent* NewUpdatedComponent |
Assign the component we move and update. | |
| bool | ShouldSkipUpdate
(
float DeltaTime |
Possibly skip update if moved component is not rendered or can't move. | |
| float | SlideAlongSurface
(
const FVector& Delta, |
Slide smoothly along a surface, and slide away from multiple impacts using TwoWallAdjust if necessary. | |
| void | Snap the updated component to the plane constraint, if enabled. | ||
| void | Stops movement immediately (zeroes velocity, usually zeros acceleration for components with acceleration). | ||
| void | TwoWallAdjust
(
FVector& Delta, |
Compute a movement direction when contacting two surfaces. | |
| void | Update ComponentVelocity of UpdatedComponent. | ||
| void | Update tick registration state, determined by bAutoUpdateTickRegistration. |
Overridden from UActorComponent
| Type | Name | Description | |
|---|---|---|---|
| void | Deactivate () |
Deactivates the SceneComponent. | |
| void | Overridden to auto-register the updated component if it starts NULL, and we can find a root component on our owner. | ||
| void | OnRegister () |
Overridden to update component properties that should be updated while being edited. | |
| void | RegisterComponentTickFunctions
(
bool bRegister |
Virtual call chain to register all tick functions | |
| void | TickComponent
(
float DeltaTime, |
Function called every frame on this ActorComponent. |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
Called when a property on this object has been modified externally | |
| void | PostLoad () |
Do any object-specific cleanup required immediately after loading an object. | |
| void | Handles reading, writing, and reference collecting using FArchive. |