Navigation
API > API/Runtime > API/Runtime/Engine
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.
| Name | UMovementComponent |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/GameFramework/MovementComponent.h |
| Include Path | #include "GameFramework/MovementComponent.h" |
Syntax
UCLASS (ClassGroup=Movement, Abstract, BlueprintType, MinimalAPI)
class UMovementComponent : public UActorComponent
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UActorComponent → UMovementComponent
Implements Interfaces
Derived Classes
- UInterpToMovementComponent
- UNavMovementComponent
- UProjectileMovementComponent
- URotatingMovementComponent
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UMovementComponent
(
const FObjectInitializer& ObjectInitializer |
GameFramework/MovementComponent.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bAutoRegisterPhysicsVolumeUpdates | uint8 | If true, then applies the value of bComponentShouldUpdatePhysicsVolume to the UpdatedComponent. | GameFramework/MovementComponent.h |
|
| bAutoRegisterUpdatedComponent | uint8 | If true, registers the owner's Root component as the UpdatedComponent if there is not one currently assigned. | GameFramework/MovementComponent.h |
|
| bAutoUpdateTickRegistration | uint8 | If true, whenever the updated component is changed, this component will enable or disable its tick dependent on whether it has something to update. | GameFramework/MovementComponent.h |
|
| bComponentShouldUpdatePhysicsVolume | uint8 | If true, enables bShouldUpdatePhysicsVolume on the UpdatedComponent during initialization from SetUpdatedComponent(), otherwise disables such updates. | GameFramework/MovementComponent.h |
|
| bConstrainToPlane | uint8 | If true, movement will be constrained to a plane. | GameFramework/MovementComponent.h |
|
| bSnapToPlaneAtStart | uint8 | If true and plane constraints are enabled, then the updated component will be snapped to the plane when first attached. | GameFramework/MovementComponent.h |
|
| bTickBeforeOwner | uint8 | If true, after registration we will add a tick dependency to tick before our owner (if we can both tick). | GameFramework/MovementComponent.h |
|
| bUpdateOnlyIfRendered | uint8 | If true, skips TickComponent() if UpdatedComponent was not recently rendered. | GameFramework/MovementComponent.h |
|
| MoveComponentFlags | EMoveComponentFlags | Flags that control the behavior of calls to MoveComponent() on our UpdatedComponent. | GameFramework/MovementComponent.h | |
| UpdatedComponent | TObjectPtr< USceneComponent > | The component we move and update. | GameFramework/MovementComponent.h |
|
| UpdatedPrimitive | TObjectPtr< UPrimitiveComponent > | UpdatedComponent, cast as a UPrimitiveComponent. | GameFramework/MovementComponent.h |
|
| Velocity | FVector | Current velocity of updated component. | GameFramework/MovementComponent.h |
|
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bEditorWarnedStaticMobilityMove | uint8 | Warned about trying to move something with static mobility. | GameFramework/MovementComponent.h | |
| bInInitializeComponent | bool | Transient flag indicating whether we are executing InitializeComponent(). | GameFramework/MovementComponent.h | |
| bInOnRegister | bool | Transient flag indicating whether we are executing OnRegister(). | GameFramework/MovementComponent.h | |
| PlaneConstraintAxisSetting | EPlaneConstraintAxisSetting | Setting that controls behavior when movement is restricted to a 2D plane defined by a specific axis/normal, so that movement along the locked axis is not be possible. | GameFramework/MovementComponent.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void AddRadialForce
(
const FVector& Origin, |
Adds force from radial force components. | GameFramework/MovementComponent.h | |
virtual void AddRadialImpulse
(
const FVector& Origin, |
Adds impulse from radial force components. | GameFramework/MovementComponent.h | |
virtual FVector ComputeSlideVector
(
const FVector& Delta, |
Compute a vector to slide along a surface, given an attempted move, time, and normal. | GameFramework/MovementComponent.h | |
virtual FVector ConstrainDirectionToPlane
(
FVector Direction |
Constrain a direction vector to the plane constraint, if enabled. | GameFramework/MovementComponent.h |
|
virtual FVector ConstrainLocationToPlane
(
FVector Location |
Constrain a position vector to the plane constraint, if enabled. | GameFramework/MovementComponent.h |
|
virtual FVector ConstrainNormalToPlane
(
FVector Normal |
Constrain a normal vector (of unit length) to the plane constraint, if enabled. | GameFramework/MovementComponent.h |
|
virtual float GetGravityZ() |
Returns gravity that affects this component | GameFramework/MovementComponent.h |
|
virtual float GetMaxSpeed() |
Returns maximum speed of component in current movement mode. | GameFramework/MovementComponent.h |
|
virtual FVector GetPenetrationAdjustment
(
const FHitResult& Hit |
Calculate a movement adjustment to try to move out of a penetration from a failed move. | GameFramework/MovementComponent.h | |
virtual APhysicsVolume * GetPhysicsVolume() |
Returns the PhysicsVolume this MovementComponent is using, or the world's default physics volume if none. | GameFramework/MovementComponent.h |
|
EPlaneConstraintAxisSetting GetPlaneConstraintAxisSetting() |
Get the plane constraint axis setting. | GameFramework/MovementComponent.h |
|
const FVector & GetPlaneConstraintNormal() |
Returns the normal of the plane that constrains movement, enforced if the plane constraint is enabled. | GameFramework/MovementComponent.h |
|
const FVector & GetPlaneConstraintOrigin () |
Get the plane constraint origin. | GameFramework/MovementComponent.h |
|
virtual void HandleImpact
(
const FHitResult& Hit, |
Called for Blocking impact | GameFramework/MovementComponent.h | |
virtual void InitCollisionParams
(
FCollisionQueryParams& OutParams, |
Initialize collision params appropriately based on our collision settings. | GameFramework/MovementComponent.h | |
virtual 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. | GameFramework/MovementComponent.h |
|
virtual bool IsInWater() |
Returns true if it's in PhysicsVolume with water flag | GameFramework/MovementComponent.h | |
bool K2_MoveUpdatedComponent
(
FVector Delta, |
Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation. | GameFramework/MovementComponent.h |
|
bool MoveUpdatedComponent
(
const FVector& Delta, |
GameFramework/MovementComponent.h | ||
bool MoveUpdatedComponent
(
const FVector& Delta, |
Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation. | GameFramework/MovementComponent.h | |
virtual void OnTeleported() |
Called by owning Actor upon successful teleport from AActor::TeleportTo(). | GameFramework/MovementComponent.h | |
virtual bool OverlapTest
(
const FVector& Location, |
Return true if the given collision shape overlaps other geometry at the given location and rotation. | GameFramework/MovementComponent.h | |
virtual void PhysicsVolumeChanged
(
APhysicsVolume* NewVolume |
Delegate when PhysicsVolume of UpdatedComponent has been changed | GameFramework/MovementComponent.h | |
bool ResolvePenetration
(
const FVector& Adjustment, |
GameFramework/MovementComponent.h | ||
bool ResolvePenetration
(
const FVector& Adjustment, |
Try to move out of penetration in an object after a failed move. | GameFramework/MovementComponent.h | |
virtual bool SafeMoveUpdatedComponent
(
const FVector& Delta, |
Calls MoveUpdatedComponent(), handling initial penetrations by calling ResolvePenetration(). | GameFramework/MovementComponent.h | |
bool SafeMoveUpdatedComponent
(
const FVector& Delta, |
GameFramework/MovementComponent.h | ||
virtual void SetPlaneConstraintAxisSetting
(
EPlaneConstraintAxisSetting NewAxisSetting |
Set the plane constraint axis setting. | GameFramework/MovementComponent.h |
|
virtual void SetPlaneConstraintEnabled
(
bool bEnabled |
Sets whether or not the plane constraint is enabled. | GameFramework/MovementComponent.h |
|
virtual void SetPlaneConstraintFromVectors
(
FVector Forward, |
Uses the Forward and Up vectors to compute the plane that constrains movement, enforced if the plane constraint is enabled. | GameFramework/MovementComponent.h |
|
virtual void SetPlaneConstraintNormal
(
FVector PlaneNormal |
Sets the normal of the plane that constrains movement, enforced if the plane constraint is enabled. | GameFramework/MovementComponent.h |
|
virtual void SetPlaneConstraintOrigin
(
FVector PlaneOrigin |
Sets the origin of the plane that constrains movement, enforced if the plane constraint is enabled. | GameFramework/MovementComponent.h |
|
virtual void SetUpdatedComponent
(
USceneComponent* NewUpdatedComponent |
Assign the component we move and update. | GameFramework/MovementComponent.h |
|
virtual bool ShouldSkipUpdate
(
float DeltaTime |
Possibly skip update if moved component is not rendered or can't move. | GameFramework/MovementComponent.h | |
virtual float SlideAlongSurface
(
const FVector& Delta, |
Slide smoothly along a surface, and slide away from multiple impacts using TwoWallAdjust if necessary. | GameFramework/MovementComponent.h | |
virtual void SnapUpdatedComponentToPlane() |
Snap the updated component to the plane constraint, if enabled. | GameFramework/MovementComponent.h |
|
virtual void StopMovementImmediately() |
Stops movement immediately (zeroes velocity, usually zeros acceleration for components with acceleration). | GameFramework/MovementComponent.h |
|
virtual void TwoWallAdjust
(
FVector& Delta, |
Compute a movement direction when contacting two surfaces. | GameFramework/MovementComponent.h | |
virtual void UpdateComponentVelocity () |
Update ComponentVelocity of UpdatedComponent. | GameFramework/MovementComponent.h | |
virtual void UpdateTickRegistration () |
Update tick registration state, determined by bAutoUpdateTickRegistration. | GameFramework/MovementComponent.h |
Overridden from UActorComponent
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void Deactivate() |
Deactivates the SceneComponent. | GameFramework/MovementComponent.h | |
virtual void InitializeComponent() |
Overridden to auto-register the updated component if it starts NULL, and we can find a root component on our owner. | GameFramework/MovementComponent.h | |
virtual void OnRegister() |
Overridden to update component properties that should be updated while being edited. | GameFramework/MovementComponent.h | |
virtual void RegisterComponentTickFunctions
(
bool bRegister |
Virtual call chain to register all tick functions | GameFramework/MovementComponent.h | |
virtual void TickComponent
(
float DeltaTime, |
Function called every frame on this ActorComponent. | GameFramework/MovementComponent.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void PostEditChangeProperty
(
FPropertyChangedEvent& PropertyChangedEvent |
GameFramework/MovementComponent.h | ||
virtual void PostLoad() |
GameFramework/MovementComponent.h | ||
virtual void Serialize
(
FArchive& Ar |
GameFramework/MovementComponent.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FVector GetPlaneConstraintNormalFromAxisSetting
(
EPlaneConstraintAxisSetting AxisSetting |
Helper to compute the plane constraint axis from the current setting. | GameFramework/MovementComponent.h | |
virtual bool MoveUpdatedComponentImpl
(
const FVector& Delta, |
GameFramework/MovementComponent.h | ||
virtual bool ResolvePenetrationImpl
(
const FVector& Adjustment, |
GameFramework/MovementComponent.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void PhysicsLockedAxisSettingChanged() |
GameFramework/MovementComponent.h |