UMovementComponent

MovementComponent is an abstract component class that defines functionality for moving a PrimitiveComponent (our UpdatedComponent) each tick.

Windows
MacOS
Linux

Inheritance Hierarchy

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

Name Description

Public variable

uint8: 1

 

bAutoRegisterPhysicsVolumeUpdates

If true, then applies the value of bComponentShouldUpdatePhysicsVolume to the UpdatedComponent.

Public variable

uint8: 1

 

bAutoRegisterUpdatedComponent

If true, registers the owner's Root component as the UpdatedComponent if there is not one currently assigned.

Public variable

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.

Public variable

uint8: 1

 

bComponentShouldUpdatePhysicsVolume

If true, enables bShouldUpdatePhysicsVolume on the UpdatedComponent during initialization from SetUpdatedComponent(), otherwise disables such updates.

Public variable

uint8: 1

 

bConstrainToPlane

If true, movement will be constrained to a plane.

Public variable

uint8: 1

 

bSnapToPlaneAtStart

If true and plane constraints are enabled, then the updated component will be snapped to the plane when first attached.

Public variable

uint8: 1

 

bTickBeforeOwner

If true, after registration we will add a tick dependency to tick before our owner (if we can both tick).

Public variable

uint8: 1

 

bUpdateOnlyIfRendered

If true, skips TickComponent() if UpdatedComponent was not recently rendered.

Public variable

EMoveComponentF...

 

MoveComponentFlags

Flags that control the behavior of calls to MoveComponent() on our UpdatedComponent.

Protected variable

FVector

 

PlaneConstraintNormal

The normal or axis of the plane that constrains movement, if bConstrainToPlane is enabled.

Protected variable

FVector

 

PlaneConstraintOrigin

The origin of the plane that constrains movement, if plane constraint is enabled.

Public variable

USceneComponent...

 

UpdatedComponent

The component we move and update.

Public variable

UPrimitiveCompo...

 

UpdatedPrimitive

UpdatedComponent, cast as a UPrimitiveComponent.

Public variable

FVector

 

Velocity

Current velocity of updated component.

Constructors

Name Description

Public function

UMovementComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Virtual

void

 

AddRadialForce

(
    const FVector& Origin,
    float Radius,
    float Strength,
    ERadialImpulseFalloff Falloff
)

Adds force from radial force components.

Public function Virtual

void

 

AddRadialImpulse

(
    const FVector& Origin,
    float Radius,
    float Strength,
    ERadialImpulseFalloff Falloff,
    bool bVelChange
)

Adds impulse from radial force components.

Public function Virtual Const

FVector

 

ComputeSlideVector

(
    const FVector& Delta,
    const float Time,
    const FVector& Normal,
    const FHitResult& Hit
)

Compute a vector to slide along a surface, given an attempted move, time, and normal.

Public function Virtual Const

FVector

 

ConstrainDirectionToPlane

(
    FVector Direction
)

Constrain a direction vector to the plane constraint, if enabled.

Public function Virtual Const

FVector

 

ConstrainLocationToPlane

(
    FVector Location
)

Constrain a position vector to the plane constraint, if enabled.

Public function Virtual Const

FVector

 

ConstrainNormalToPlane

(
    FVector Normal
)

Constrain a normal vector (of unit length) to the plane constraint, if enabled.

Public function Virtual Const

float

 

GetGravityZ()

Returns gravity that affects this component

Public function Virtual Const

float

 

GetMaxSpeed()

Returns maximum speed of component in current movement mode.

Public function Virtual Const

FVector

 

GetPenetrationAdjustment

(
    const FHitResult& Hit
)

Calculate a movement adjustment to try to move out of a penetration from a failed move.

Public function Virtual Const

APhysicsVolu...

 

GetPhysicsVolume()

Returns the PhysicsVolume this MovementComponent is using, or the world's default physics volume if none.

Public function Const

EPlaneConstr...

 

GetPlaneConstraintAxisSetting()

Get the plane constraint axis setting.

Public function Const

const FVecto...

 

GetPlaneConstraintNormal()

Returns the normal of the plane that constrains movement, enforced if the plane constraint is enabled.

Protected function Const

FVector

 

GetPlaneConstraintNormalFromAxisSetting

(
    EPlaneConstraintAxisSetting AxisSet...
)

Helper to compute the plane constraint axis from the current setting.

Public function Const

const FVecto...

 

GetPlaneConstraintOrigin()

Get the plane constraint origin.

Public function Virtual

void

 

HandleImpact

(
    const FHitResult& Hit,
    float TimeSlice,
    const FVector& MoveDelta
)

Called for Blocking impact

Public function Virtual Const

void

 

InitCollisionParams

(
    FCollisionQueryParams& OutParams,
    FCollisionResponseParams& OutRespo...
)

Initialize collision params appropriately based on our collision settings.

Public function Virtual Const

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.

Public function Virtual Const

bool

 

IsInWater()

Returns true if it's in PhysicsVolume with water flag

Public function Virtual Const

float

 

K2_GetMaxSpeedModifier()

Returns a scalar applied to the maximum velocity that the component can currently move.

Public function Virtual Const

float

 

K2_GetModifiedMaxSpeed()

Returns the result of GetMaxSpeed() * GetMaxSpeedModifier().

Public function

bool

 

K2_MoveUpdatedComponent

(
    FVector Delta,
    FRotator NewRotation,
    FHitResult& OutHit,
    bool bSweep,
    bool bTeleport
)

Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation.

Public function

bool

 

MoveUpdatedComponent

(
    const FVector& Delta,
    const FRotator& NewRotation,
    bool bSweep,
    FHitResult* OutHit,
    ETeleportType Teleport
)

Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation.

Public function

bool

 

MoveUpdatedComponent

(
    const FVector& Delta,
    const FQuat& NewRotation,
    bool bSweep,
    FHitResult* OutHit,
    ETeleportType Teleport
)

Moves our UpdatedComponent by the given Delta, and sets rotation to NewRotation.

Protected function Virtual

bool

 

MoveUpdatedComponentImpl

(
    const FVector& Delta,
    const FQuat& NewRotation,
    bool bSweep,
    FHitResult* OutHit,
    ETeleportType Teleport
)

Public function Virtual

void

 

OnTeleported()

Called by owning Actor upon successful teleport from AActor::TeleportTo().

Public function Virtual Const

bool

 

OverlapTest

(
    const FVector& Location,
    const FQuat& RotationQuat,
    const ECollisionChannel CollisionCh...,
    const FCollisionShape& CollisionSh...,
    const AActor* IgnoreActor
)

Return true if the given collision shape overlaps other geometry at the given location and rotation.

Public function Static

void

 

PhysicsLockedAxisSettingChanged()

Public function Virtual

void

 

PhysicsVolumeChanged

(
    APhysicsVolume* NewVolume
)

Delegate when PhysicsVolume of UpdatedComponent has been changed

Public function

bool

 

ResolvePenetration

(
    const FVector& Adjustment,
    const FHitResult& Hit,
    const FRotator& NewRotation
)

Public function

bool

 

ResolvePenetration

(
    const FVector& Adjustment,
    const FHitResult& Hit,
    const FQuat& NewRotation
)

Try to move out of penetration in an object after a failed move.

Protected function Virtual

bool

 

ResolvePenetrationImpl

(
    const FVector& Adjustment,
    const FHitResult& Hit,
    const FQuat& NewRotation
)

Public function

bool

 

SafeMoveUpdatedComponent

(
    const FVector& Delta,
    const FQuat& NewRotation,
    bool bSweep,
    FHitResult& OutHit,
    ETeleportType Teleport
)

Calls MoveUpdatedComponent(), handling initial penetrations by calling ResolvePenetration().

Public function

bool

 

SafeMoveUpdatedComponent

(
    const FVector& Delta,
    const FRotator& NewRotation,
    bool bSweep,
    FHitResult& OutHit,
    ETeleportType Teleport
)

Calls MoveUpdatedComponent(), handling initial penetrations by calling ResolvePenetration().

Public function Virtual

void

 

SetPlaneConstraintAxisSetting

(
    EPlaneConstraintAxisSetting NewAxis...
)

Set the plane constraint axis setting.

Public function Virtual

void

 

SetPlaneConstraintEnabled

(
    bool bEnabled
)

Sets whether or not the plane constraint is enabled.

Public function Virtual

void

 

SetPlaneConstraintFromVectors

(
    FVector Forward,
    FVector Up
)

Uses the Forward and Up vectors to compute the plane that constrains movement, enforced if the plane constraint is enabled.

Public function Virtual

void

 

SetPlaneConstraintNormal

(
    FVector PlaneNormal
)

Sets the normal of the plane that constrains movement, enforced if the plane constraint is enabled.

Public function Virtual

void

 

SetPlaneConstraintOrigin

(
    FVector PlaneOrigin
)

Sets the origin of the plane that constrains movement, enforced if the plane constraint is enabled.

Public function Virtual

void

 

SetUpdatedComponent

(
    USceneComponent* NewUpdatedCom...
)

Assign the component we move and update.

Public function Virtual Const

bool

 

ShouldSkipUpdate

(
    float DeltaTime
)

Possibly skip update if moved component is not rendered or can't move.

Public function Virtual

float

 

SlideAlongSurface

(
    const FVector& Delta,
    float Time,
    const FVector& Normal,
    FHitResult& Hit,
    bool bHandleImpact
)

Slide smoothly along a surface, and slide away from multiple impacts using TwoWallAdjust if necessary.

Public function Virtual

void

 

SnapUpdatedComponentToPlane()

Snap the updated component to the plane constraint, if enabled.

Public function Virtual

void

 

StopMovementImmediately()

Stops movement immediately (zeroes velocity, usually zeros acceleration for components with acceleration).

Public function Virtual Const

void

 

TwoWallAdjust

(
    FVector& Delta,
    const FHitResult& Hit,
    const FVector& OldHitNormal
)

Compute a movement direction when contacting two surfaces.

Public function Virtual

void

 

UpdateComponentVelocity()

Update ComponentVelocity of UpdatedComponent.

Public function Virtual

void

 

UpdateTickRegistration()

Update tick registration state, determined by bAutoUpdateTickRegistration.

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

Deactivate()

Deactivates the SceneComponent.

Public function Virtual

void

 

InitializeComponent()

Overridden to auto-register the updated component if it starts NULL, and we can find a root component on our owner.

Public function Virtual

void

 

OnRegister()

Overridden to update component properties that should be updated while being edited.

Public function Virtual

void

 

RegisterComponentTickFunctions

(
    bool bRegister
)

Virtual call chain to register all tick functions

Public function Virtual

void

 

TickComponent

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorComponentTickFunction* T...
)

Function called every frame on this ActorComponent.

Overridden from UObject

Name Description

Public function Virtual

void

 

PostEditChangeProperty

(
    FPropertyChangedEvent& PropertyCha...
)

Called when a property on this object has been modified externally

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Deprecated Functions

Name Description

Public function Virtual Const

float

 

GetMaxSpeedModifier()

GetMaxSpeedModifier() is deprecated, apply your own modifiers to GetMaxSpeed() if desired.

Public function Virtual Const

float

 

GetModifiedMaxSpeed()

GetModifiedMaxSpeed() is deprecated, use GetMaxSpeed() instead.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback