Language:
Discover
By Skill Level
By Category

UProjectileMovementComponent

Choose your OS:

Inheritance Hierarchy

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

 

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).

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 Virtual

bool

 

CheckStillInWorld()

End UMovementComponent Interface.

Protected function Virtual

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.

Protected function Virtual

FVector

 

ComputeHomingAcceleration

(
    const FVector & InVelocity,
    float DeltaTime
)

Allow the projectile to track towards its homing target.

Protected function Virtual

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

FVector

 

ComputeVelocity

(
    FVector InitialVelocity,
    float DeltaTime
)

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

Public function

float

 

GetBuoyancy()

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

Public function

USceneCompon ...

 

GetInterpolatedComponent()

Returns the component used for network interpolation.

Public function

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

bool

 

IsInterpolationComplete()

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

Public function

bool

 

IsVelocityUnderSimulationThreshold()

Returns true if velocity magnitude is less than BounceVelocityStopSimulatingThreshold.

Protected function

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

bool

 

ShouldApplyGravity()

Public function Virtual

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

float

 

GetGravityZ()

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

Public function Virtual

float

 

GetMaxSpeed()

End UActorComponent Interface.

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...
)

Begin UActorComponent Interface.

Overridden from UObject

Name Description

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object, and immediately after any undo/redo.

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

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/ProjectileMovementComponent.h