UProjectileMovementComponent

ProjectileMovementComponent updates the position of another component during its tick.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/GameFramework/ProjectileMovementComponent.h

Include

#include "GameFramework/ProjectileMovementComponent.h"

Syntax

class UProjectileMovementComponent : public UMovementComponent

Remarks

ProjectileMovementComponent updates the position of another component during its tick.

Behavior such as bouncing after impacts and homing toward a target are supported.

Normally the root component of the owning actor is moved, however another component may be selected (see SetUpdatedComponent()). If the updated component is simulating physics, only the initial launch parameters (when initial velocity is non-zero) will affect the projectile, and the physics sim will take over from there.

Variables

Name Description

Public variable

uint8: 1

 

bBounceAngleAffectsFriction

Controls the effects of friction on velocity parallel to the impact surface when bouncing.

Public variable

uint8: 1

 

bForceSubStepping

If true, forces sub-stepping to break up movement into discrete smaller steps to improve accuracy of the trajectory.

Public variable

uint8: 1

 

bInitialVelocityInLocalSpace

If true, the initial Velocity is interpreted as being in local space upon startup.

Public variable

uint8: 1

 

bInterpMovement

If true and there is an interpolated component set, location (and optionally rotation) interpolation is enabled which allows the interpolated object to smooth uneven updates of the UpdatedComponent's location (usually to smooth network updates).

Protected variable

uint8: 1

 

bInterpolationComplete

Public variable

uint8: 1

 

bInterpRotation

If true and there is an interpolated component set, rotation interpolation is enabled which allows the interpolated object to smooth uneven updates of the UpdatedComponent's rotation (usually to smooth network updates).

Public variable

uint8: 1

 

bIsHomingProjectile

If true, we will accelerate toward our homing target.

Public variable

uint8: 1

 

bIsSliding

If true, projectile is sliding / rolling along a surface.

Public variable

int32

 

BounceAdditionalIterations

On the first few bounces (up to this amount), allow extra iterations over MaxSimulationIterations if necessary.

Public variable

float

 

BounceVelocityStopSimulatingThreshold

If velocity is below this threshold after a bounce, stops simulating and triggers the OnProjectileStop event.

Public variable

float

 

Bounciness

Percentage of velocity maintained after the bounce in the direction of the normal of impact (coefficient of restitution).

Public variable

uint8: 1

 

bRotationFollowsVelocity

If true, this projectile will have its rotation updated each frame to match the direction of its velocity.

Public variable

uint8: 1

 

bRotationRemainsVertical

If true, this projectile will have its rotation updated each frame to maintain the rotations Yaw only.

Public variable

uint8: 1

 

bShouldBounce

If true, simple bounces will be simulated. Set this to false to stop simulating on contact.

Public variable

uint8: 1

 

bSimulationEnabled

If true, does normal simulation ticking and update.

Public variable

uint8: 1

 

bSweepCollision

If true, movement uses swept collision checks.

Public variable

float

 

Buoyancy

Buoyancy of UpdatedComponent in fluid. 0.0=sinks as fast as in air, 1.0=neutral buoyancy

Public variable

float

 

Friction

Coefficient of friction, affecting the resistance to sliding along a surface.

Public variable

float

 

HomingAccelerationMagnitude

The magnitude of our acceleration towards the homing target.

Public variable

TWeakObjectPtr<...

 

HomingTargetComponent

The current target we are homing towards.

Public variable

float

 

InitialSpeed

Initial speed of projectile.

Protected variable

FVector

 

InterpInitialLocationOffset

Protected variable

FQuat

 

InterpInitialRotationOffset

Public variable

float

 

InterpLocationMaxLagDistance

Max distance behind UpdatedComponent which the interpolated component is allowed to lag.

Protected variable

FVector

 

InterpLocationOffset

Public variable

float

 

InterpLocationSnapToTargetDistance

Max distance behind UpdatedComponent beyond which the interpolated component is snapped to the target location instead.

Public variable

float

 

InterpLocationTime

"Time" over which most of the location interpolation occurs, when the UpdatedComponent (target) moves ahead of the interpolated component.

Protected variable

TWeakObjectPtr<...

 

InterpolatedComponentPtr

Protected variable

FQuat

 

InterpRotationOffset

Public variable

float

 

InterpRotationTime

"Time" over which most of the rotation interpolation occurs, when the UpdatedComponent (target) moves ahead of the interpolated component.

Public variable

int32

 

MaxSimulationIterations

Max number of iterations used for each discrete simulation step.

Public variable

float

 

MaxSimulationTimeStep

Max time delta for each discrete simulation step.

Public variable

float

 

MaxSpeed

Limit on speed of projectile (0 means no limit).

Public variable

float

 

MinFrictionFraction

When bounce angle affects friction, apply at least this fraction of normal friction.

Public variable

FOnProjectileBo...

 

OnProjectileBounce

Called when projectile impacts something and bounces are enabled.

Public variable

FOnProjectileSt...

 

OnProjectileStop

Called when projectile has come to a stop (velocity is below simulation threshold, bounces are disabled, or it is forcibly stopped).

Protected variable

FVector

 

PendingForceThisUpdate

Double-buffer of pending force so that updates can use the accumulated value and reset the data so other AddForce() calls work correctly.

Public variable

FVector

 

PreviousHitNormal

Saved HitResult Normal from previous simulation step that resulted in an impact.

Public variable

float

 

PreviousHitTime

Saved HitResult Time (0 to 1) from previous simulation step. Equal to 1.0 when there was no impact.

Public variable

float

 

ProjectileGravityScale

Custom gravity scale for this projectile. Set to 0 for no gravity.

Constructors

Name Description

Public function

UProjectileMovementComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function

void

 

AddForce

(
    FVector Force
)

Adds a force which is accumulated until next tick, used by ComputeAcceleration() to affect Velocity.

Public function Virtual

bool

 

CheckStillInWorld()

This will check to see if the projectile is still in the world.

Public function

void

 

ClearPendingForce

(
    bool bClearImmediateForce
)

Clears any pending forces from AddForce().

Public function Virtual Const

FVector

 

ComputeAcceleration

(
    const FVector& InVelocity,
    float DeltaTime
)

Compute the acceleration that will be applied

Protected function Virtual

FVector

 

ComputeBounceResult

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

Computes result of a bounce and returns the new velocity.

Public function Virtual Const

FVector

 

ComputeHomingAcceleration

(
    const FVector& InVelocity,
    float DeltaTime
)

Allow the projectile to track towards its homing target.

Public function Virtual Const

FVector

 

ComputeMoveDelta

(
    const FVector& InVelocity,
    float DeltaTime
)

Compute the distance we should move in the given time, at a given a velocity.

Public function Virtual Const

FVector

 

ComputeVelocity

(
    FVector InitialVelocity,
    float DeltaTime
)

Given an initial velocity and a time step, compute a new velocity.

Public function Const

float

 

GetBuoyancy()

Public function Const

USceneCompon...

 

GetInterpolatedComponent()

Returns the component used for network interpolation.

Public function Const

FVector

 

GetPendingForce()

Returns the sum of pending forces from AddForce().

Public function Const

float

 

GetSimulationTimeStep

(
    float RemainingTime,
    int32 Iterations
)

Compute remaining time step given remaining time and current iterations.

Protected function Virtual

EHandleBlock...

 

HandleBlockingHit

(
    const FHitResult& Hit,
    float TimeTick,
    const FVector& MoveDelta,
    float& SubTickTimeRemaining
)

Handle blocking hit during simulation update.

Protected function Virtual

bool

 

HandleDeflection

(
    FHitResult& Hit,
    const FVector& OldVelocity,
    const uint32 NumBounces,
    float& SubTickTimeRemaining
)

Handle a blocking hit after HandleBlockingHit() returns a result indicating that deflection occured.

Protected function Virtual

bool

 

HandleSliding

(
    FHitResult& Hit,
    float& SubTickTimeRemaining
)

Handle case where projectile is sliding along a surface.

Public function

bool

 

HasStoppedSimulation()

Public function Const

bool

 

IsInterpolationComplete()

Returns whether interpolation is complete because the target has been reached.

Public function Const

bool

 

IsVelocityUnderSimulationThreshold()

Returns true if velocity magnitude is less than BounceVelocityStopSimulatingThreshold.

Public function Const

FVector

 

LimitVelocity

(
    FVector NewVelocity
)

Don't allow velocity magnitude to exceed MaxSpeed, if MaxSpeed is non-zero.

Public function Virtual

void

 

MoveInterpolationTarget

(
    const FVector& NewLocation,
    const FRotator& NewRotation
)

Moves the UpdatedComponent, which is also the interpolation target for the interpolated component.

Public function Virtual

void

 

ResetInterpolation()

Resets interpolation so that interpolated component snaps back to the initial location/rotation without any additional offsets.

Public function Virtual

void

 

SetInterpolatedComponent

(
    USceneComponent* Component
)

Assigns the component that will be used for network interpolation/smoothing.

Public function Virtual

void

 

SetVelocityInLocalSpace

(
    FVector NewVelocity
)

Sets the velocity to the new value, rotated into Actor space.

Public function Const

bool

 

ShouldApplyGravity()

Public function Virtual Const

bool

 

ShouldUseSubStepping()

Determine whether or not to use substepping in the projectile motion update.

Public function Virtual

void

 

StopSimulating

(
    const FHitResult& HitResult
)

Clears the reference to UpdatedComponent, fires stop event (OnProjectileStop), and stops ticking (if bAutoUpdateTickRegistration is true).

Protected function Virtual

void

 

TickInterpolation

(
    float DeltaTime
)

Overridden from UMovementComponent

Name Description

Public function Virtual Const

float

 

GetGravityZ()

Compute gravity effect given current physics volume, projectile gravity scale, etc.

Public function Virtual Const

float

 

GetMaxSpeed()

Returns maximum speed of component in current movement mode.

Protected function Virtual

void

 

HandleImpact

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

Applies bounce logic if enabled to affect velocity upon impact (using ComputeBounceResult()), or stops the projectile if bounces are not enabled or velocity is below BounceVelocityStopSimulatingThreshold.

Public function Virtual

void

 

UpdateTickRegistration()

Update tick registration state, determined by bAutoUpdateTickRegistration.

Overridden from UActorComponent

Name Description

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

 

TickComponent

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

Function called every frame on this ActorComponent.

Overridden from UObject

Name Description

Public function Virtual

void

 

PostLoad()

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

Classes

Enums

Name

Description

Protected enum

EHandleBlockingHitResult

Enum indicating how simulation should proceed after HandleBlockingHit() is called.

Constants

Name

Description

MIN_TICK_TIME

Minimum delta time considered when ticking.

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss