Navigation
API > API/Runtime > API/Runtime/Engine
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.
| Name | UProjectileMovementComponent |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/GameFramework/ProjectileMovementComponent.h |
| Include Path | #include "GameFramework/ProjectileMovementComponent.h" |
Syntax
UCLASS (ClassGroup=Movement, Meta=(BlueprintSpawnableComponent), ShowCategories=(Velocity),
MinimalAPI)
class UProjectileMovementComponent : public UMovementComponent
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UActorComponent → UMovementComponent → UProjectileMovementComponent
Implements Interfaces
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UProjectileMovementComponent
(
const FObjectInitializer& ObjectInitializer |
GameFramework/ProjectileMovementComponent.h |
Classes
| Name | Remarks |
|---|---|
| FOnProjectileBounceDelegate | |
| FOnProjectileStopDelegate |
Enums
Protected
| Name | Remarks |
|---|---|
| EHandleBlockingHitResult | Enum indicating how simulation should proceed after HandleBlockingHit() is called. |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| MIN_TICK_TIME | const float | Minimum delta time considered when ticking. | GameFramework/ProjectileMovementComponent.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bBounceAngleAffectsFriction | uint8 | Controls the effects of friction on velocity parallel to the impact surface when bouncing. | GameFramework/ProjectileMovementComponent.h |
|
| bForceSubStepping | uint8 | If true, forces sub-stepping to break up movement into discrete smaller steps to improve accuracy of the trajectory. | GameFramework/ProjectileMovementComponent.h |
|
| bInitialVelocityInLocalSpace | uint8 | If true, the initial Velocity is interpreted as being in local space upon startup. | GameFramework/ProjectileMovementComponent.h |
|
| bInterpMovement | uint8 | 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). | GameFramework/ProjectileMovementComponent.h |
|
| bInterpolationUseScopedMovement | uint8 | If true, uses FScopedMovementUpdate to avoid moving the attached interpolated object's children more than once during a tick when it would both interpolate and move during projectile simulation. | GameFramework/ProjectileMovementComponent.h |
|
| bInterpRotation | uint8 | 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). | GameFramework/ProjectileMovementComponent.h |
|
| bIsHomingProjectile | uint8 | If true, we will accelerate toward our homing target. | GameFramework/ProjectileMovementComponent.h |
|
| bIsSliding | uint8 | If true, projectile is sliding / rolling along a surface. | GameFramework/ProjectileMovementComponent.h |
|
| BounceAdditionalIterations | int32 | On the first few bounces (up to this amount), allow extra iterations over MaxSimulationIterations if necessary. | GameFramework/ProjectileMovementComponent.h |
|
| BounceVelocityStopSimulatingThreshold | float | If velocity is below this threshold after a bounce, stops simulating and triggers the OnProjectileStop event. | GameFramework/ProjectileMovementComponent.h |
|
| Bounciness | float | Percentage of velocity maintained after the bounce in the direction of the normal of impact (coefficient of restitution). | GameFramework/ProjectileMovementComponent.h |
|
| bRotationFollowsVelocity | uint8 | If true, this projectile will have its rotation updated each frame to match the direction of its velocity. | GameFramework/ProjectileMovementComponent.h |
|
| bRotationRemainsVertical | uint8 | If true, this projectile will have its rotation updated each frame to maintain the rotations Yaw only. | GameFramework/ProjectileMovementComponent.h |
|
| bShouldBounce | uint8 | If true, simple bounces will be simulated. Set this to false to stop simulating on contact. | GameFramework/ProjectileMovementComponent.h |
|
| bSimulationEnabled | uint8 | If true, does normal simulation ticking and update. | GameFramework/ProjectileMovementComponent.h |
|
| bSimulationUseScopedMovement | uint8 | If true, uses FScopedMovementUpdate to avoid moving the UpdatedComponent more than once during a tick during simulation. | GameFramework/ProjectileMovementComponent.h |
|
| bSweepCollision | uint8 | If true, movement uses swept collision checks. | GameFramework/ProjectileMovementComponent.h |
|
| bThrottleInterpolation | uint8 | If true, throttle interpolation when not relevant. | GameFramework/ProjectileMovementComponent.h |
|
| Buoyancy | float | Buoyancy of UpdatedComponent in fluid. 0.0=sinks as fast as in air, 1.0=neutral buoyancy | GameFramework/ProjectileMovementComponent.h | |
| Friction | float | Coefficient of friction, affecting the resistance to sliding along a surface. | GameFramework/ProjectileMovementComponent.h |
|
| HomingAccelerationMagnitude | float | The magnitude of our acceleration towards the homing target. | GameFramework/ProjectileMovementComponent.h |
|
| HomingTargetComponent | TWeakObjectPtr< USceneComponent > | The current target we are homing towards. | GameFramework/ProjectileMovementComponent.h |
|
| InitialSpeed | float | Initial speed of projectile. | GameFramework/ProjectileMovementComponent.h |
|
| InterpLocationMaxLagDistance | float | Max distance behind UpdatedComponent which the interpolated component is allowed to lag. | GameFramework/ProjectileMovementComponent.h |
|
| InterpLocationSnapToTargetDistance | float | Max distance behind UpdatedComponent beyond which the interpolated component is snapped to the target location instead. | GameFramework/ProjectileMovementComponent.h |
|
| InterpLocationTime | float | "Time" over which most of the location interpolation occurs, when the UpdatedComponent (target) moves ahead of the interpolated component. | GameFramework/ProjectileMovementComponent.h |
|
| InterpRotationTime | float | "Time" over which most of the rotation interpolation occurs, when the UpdatedComponent (target) moves ahead of the interpolated component. | GameFramework/ProjectileMovementComponent.h |
|
| MaxSimulationIterations | int32 | Max number of iterations used for each discrete simulation step. | GameFramework/ProjectileMovementComponent.h |
|
| MaxSimulationTimeStep | float | Max time delta for each discrete simulation step. | GameFramework/ProjectileMovementComponent.h |
|
| MaxSpeed | float | Limit on speed of projectile (0 means no limit). | GameFramework/ProjectileMovementComponent.h |
|
| MinFrictionFraction | float | When bounce angle affects friction, apply at least this fraction of normal friction. | GameFramework/ProjectileMovementComponent.h |
|
| OnProjectileBounce | FOnProjectileBounceDelegate | Called when projectile impacts something and bounces are enabled. | GameFramework/ProjectileMovementComponent.h |
|
| OnProjectileStop | FOnProjectileStopDelegate | Called when projectile has come to a stop (velocity is below simulation threshold, bounces are disabled, or it is forcibly stopped). | GameFramework/ProjectileMovementComponent.h |
|
| PreviousHitNormal | FVector | Saved HitResult Normal from previous simulation step that resulted in an impact. | GameFramework/ProjectileMovementComponent.h |
|
| PreviousHitTime | float | Saved HitResult Time (0 to 1) from previous simulation step. Equal to 1.0 when there was no impact. | GameFramework/ProjectileMovementComponent.h |
|
| ProjectileGravityScale | float | Custom gravity scale for this projectile. Set to 0 for no gravity. | GameFramework/ProjectileMovementComponent.h |
|
| ThrottleInterpolationSkipFramesNotRecent | int32 | When not recently relevant, skip this many frames of interpolation if throttling is enabled. | GameFramework/ProjectileMovementComponent.h |
|
| ThrottleInterpolationSkipFramesRecent | int32 | When recently relevant, skip this many frames of interpolation if throttling is enabled. | GameFramework/ProjectileMovementComponent.h |
|
| ThrottleInterpolationThresholdNotRenderedLongTime | float | Time after not rendered for a long time when we consider throttling interpolation. | GameFramework/ProjectileMovementComponent.h |
|
| ThrottleInterpolationThresholdNotRenderedShortTime | float | Time after not rendered recently when we consider throttling interpolation. | GameFramework/ProjectileMovementComponent.h |
|
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| PendingForce | FVector | Pending force for next tick. | GameFramework/ProjectileMovementComponent.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddForce
(
FVector Force |
Adds a force which is accumulated until next tick, used by ComputeAcceleration() to affect Velocity. | GameFramework/ProjectileMovementComponent.h | |
virtual bool CheckStillInWorld () |
This will check to see if the projectile is still in the world. | GameFramework/ProjectileMovementComponent.h | |
void ClearPendingForce
(
bool bClearImmediateForce |
Clears any pending forces from AddForce(). | GameFramework/ProjectileMovementComponent.h | |
virtual FVector ComputeAcceleration
(
const FVector& InVelocity, |
Compute the acceleration that will be applied | GameFramework/ProjectileMovementComponent.h | |
virtual FVector ComputeHomingAcceleration
(
const FVector& InVelocity, |
Allow the projectile to track towards its homing target. | GameFramework/ProjectileMovementComponent.h | |
virtual FVector ComputeMoveDelta
(
const FVector& InVelocity, |
Compute the distance we should move in the given time, at a given a velocity. | GameFramework/ProjectileMovementComponent.h | |
virtual FVector ComputeVelocity
(
FVector InitialVelocity, |
Given an initial velocity and a time step, compute a new velocity. | GameFramework/ProjectileMovementComponent.h | |
float GetBuoyancy() |
GameFramework/ProjectileMovementComponent.h | ||
USceneComponent * GetInterpolatedComponent() |
Returns the component used for network interpolation. | GameFramework/ProjectileMovementComponent.h | |
FVector GetPendingForce() |
Returns the sum of pending forces from AddForce(). | GameFramework/ProjectileMovementComponent.h | |
float GetSimulationTimeStep
(
float RemainingTime, |
Compute remaining time step given remaining time and current iterations. | GameFramework/ProjectileMovementComponent.h | |
bool HasStoppedSimulation() |
GameFramework/ProjectileMovementComponent.h | ||
bool IsInterpolationComplete () |
Returns whether interpolation is complete because the target has been reached. | GameFramework/ProjectileMovementComponent.h |
|
bool IsVelocityUnderSimulationThreshold() |
Returns true if velocity magnitude is less than BounceVelocityStopSimulatingThreshold. | GameFramework/ProjectileMovementComponent.h |
|
FVector LimitVelocity
(
FVector NewVelocity |
Don't allow velocity magnitude to exceed MaxSpeed, if MaxSpeed is non-zero. | GameFramework/ProjectileMovementComponent.h |
|
virtual void MoveInterpolationTarget
(
const FVector& NewLocation, |
Moves the UpdatedComponent, which is also the interpolation target for the interpolated component. | GameFramework/ProjectileMovementComponent.h |
|
virtual void ResetInterpolation() |
Resets interpolation so that interpolated component snaps back to the initial location/rotation without any additional offsets. | GameFramework/ProjectileMovementComponent.h |
|
virtual void SetInterpolatedComponent
(
USceneComponent* Component |
Assigns the component that will be used for network interpolation/smoothing. | GameFramework/ProjectileMovementComponent.h |
|
virtual void SetVelocityInLocalSpace
(
FVector NewVelocity |
Sets the velocity to the new value, rotated into Actor space. | GameFramework/ProjectileMovementComponent.h |
|
bool ShouldApplyGravity() |
GameFramework/ProjectileMovementComponent.h | ||
virtual bool ShouldUseSubStepping () |
Determine whether or not to use substepping in the projectile motion update. | GameFramework/ProjectileMovementComponent.h | |
virtual void StopSimulating
(
const FHitResult& HitResult |
Clears the reference to UpdatedComponent, fires stop event (OnProjectileStop), and stops ticking (if bAutoUpdateTickRegistration is true). | GameFramework/ProjectileMovementComponent.h |
|
Overridden from UMovementComponent
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual float GetGravityZ() |
Compute gravity effect given current physics volume, projectile gravity scale, etc. | GameFramework/ProjectileMovementComponent.h | |
virtual float GetMaxSpeed() |
Returns maximum speed of component in current movement mode. | GameFramework/ProjectileMovementComponent.h | |
virtual void UpdateTickRegistration () |
Update tick registration state, determined by bAutoUpdateTickRegistration. | GameFramework/ProjectileMovementComponent.h |
Overridden from UActorComponent
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
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/ProjectileMovementComponent.h | |
virtual void TickComponent
(
float DeltaTime, |
Function called every frame on this ActorComponent. | GameFramework/ProjectileMovementComponent.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void PostLoad() |
GameFramework/ProjectileMovementComponent.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual FVector ComputeBounceResult
(
const FHitResult& Hit, |
Computes result of a bounce and returns the new velocity. | GameFramework/ProjectileMovementComponent.h | |
virtual int32 ComputeThrottleInterpolationMaxFrames
(
float DeltaTime, |
Determine the number of frames to allow to skip when interpolating. | GameFramework/ProjectileMovementComponent.h | |
virtual EHandleBlockingHitResult HandleBlockingHit
(
const FHitResult& Hit, |
Handle blocking hit during simulation update. | GameFramework/ProjectileMovementComponent.h | |
virtual bool HandleDeflection
(
FHitResult& Hit, |
Handle a blocking hit after HandleBlockingHit() returns a result indicating that deflection occured. | GameFramework/ProjectileMovementComponent.h | |
virtual bool HandleSliding
(
FHitResult& Hit, |
Handle case where projectile is sliding along a surface. | GameFramework/ProjectileMovementComponent.h | |
virtual void ResetThrottleInterpolation
(
float DeltaTime |
Custom hook to reset throttle interpolation tracking when it was throttling previously. | GameFramework/ProjectileMovementComponent.h | |
virtual void TickInterpolation
(
float DeltaTime |
GameFramework/ProjectileMovementComponent.h | ||
bool UpdateThrottleInterpolation
(
float DeltaTime, |
Update interpolation throttling for this frame. | GameFramework/ProjectileMovementComponent.h |
Overridden from UMovementComponent
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void HandleImpact
(
const FHitResult& Hit, |
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. | GameFramework/ProjectileMovementComponent.h |