RealDocs

UGameplayStatics::Blueprint_PredictProjectilePath_ByTraceChannel

function Engine Blueprint Since 4.15
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticBlueprintCallable

Description

Simulates a projectile arc under gravity and returns the path positions, tracing against a single collision channel for blocking hits. Prefer this over the ObjectType variant when you have a dedicated projectile trace channel.

Caveats & Gotchas

  • The default TraceChannel in Blueprint is ECC_WorldDynamic; many static geometry meshes use ECC_WorldStatic and will not block the trace unless you switch channels.
  • Each simulation step performs a sphere sweep — high SimFrequency on long arcs can generate dozens of sweep tests per call, which is expensive in busy scenes.
  • ProjectileRadius of 0 degrades the sweep to a line trace, which may miss narrow obstacles that the actual projectile would collide with.

Signature

static ENGINE_API bool Blueprint_PredictProjectilePath_ByTraceChannel(const UObject* WorldContextObject, FHitResult& OutHit, TArray<FVector>& OutPathPositions, FVector& OutLastTraceDestination, FVector StartPos, FVector LaunchVelocity, bool bTracePath, float ProjectileRadius, TEnumAsByte<ECollisionChannel> TraceChannel, bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, float DrawDebugTime, float SimFrequency = 15.f, float MaxSimTime = 2.f, float OverrideGravityZ = 0);

Parameters

Name Type Description Default
WorldContextObject const UObject* Any UObject within the world to provide world context.
OutHit FHitResult& Output: hit result if the simulated projectile hits something.
OutPathPositions TArray<FVector>& Output: ordered positions of the simulated arc from StartPos to end.
OutLastTraceDestination FVector& Output: goal position of the final trace step.
StartPos FVector Starting position of the projectile.
LaunchVelocity FVector Initial velocity of the simulated projectile.
bTracePath bool If true, sweeps along the arc checking for blocking hits.
ProjectileRadius float Radius of the simulated spherical projectile.
TraceChannel TEnumAsByte<ECollisionChannel> Collision channel to trace against.
bTraceComplex bool Whether to use complex collision geometry.
ActorsToIgnore const TArray<AActor*>& Actors to exclude from collision checks.
DrawDebugType EDrawDebugTrace::Type Controls debug visualization.
DrawDebugTime float Duration in seconds for debug lines.
SimFrequency float Simulation steps per second. 15.f
MaxSimTime float Maximum simulation time in seconds. 2.f
OverrideGravityZ float Optional gravity override; 0 uses world gravity. 0

Return Type

bool

Example

Predict throw arc for UI indicator C++
FHitResult Hit;
TArray<FVector> Path;
FVector LastDest;
TArray<AActor*> Ignored = { GetOwner() };

UGameplayStatics::Blueprint_PredictProjectilePath_ByTraceChannel(
    this, Hit, Path, LastDest,
    MuzzleLocation, ThrowVelocity,
    true, 5.f, ECC_WorldStatic,
    false, Ignored,
    EDrawDebugTrace::ForOneFrame, 0.f,
    15.f, 3.f
);

for (const FVector& Pos : Path)
{
    DrawDebugSphere(GetWorld(), Pos, 3.f, 6, FColor::Green, false, -1.f);
}

Version History

Introduced in: 4.15

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.