UGameplayStatics::Blueprint_PredictProjectilePath_ByObjectType
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Simulates a projectile arc under gravity and returns the full path as an array of positions, optionally tracing against specified object types to detect collisions. Returns true if the simulated projectile hit something.
Caveats & Gotchas
- • SimFrequency and MaxSimTime directly trade accuracy for performance — high SimFrequency with long MaxSimTime can be expensive when called every frame; cache results and re-run only when inputs change.
- • OutPathPositions is cleared and repopulated on every call; pre-allocating the array externally has no effect on allocation behaviour.
- • When bTracePath is false the function still returns path positions but always returns false, even if the arc passes through geometry.
Signature
static ENGINE_API bool Blueprint_PredictProjectilePath_ByObjectType(const UObject* WorldContextObject, FHitResult& OutHit, TArray<FVector>& OutPathPositions, FVector& OutLastTraceDestination, FVector StartPos, FVector LaunchVelocity, bool bTracePath, float ProjectileRadius, const TArray<TEnumAsByte<EObjectTypeQuery> >& ObjectTypes, 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 (not in path if a hit occurred). | — |
| StartPos | FVector | Starting position of the projectile. | — |
| LaunchVelocity | FVector | Initial velocity of the simulated projectile. | — |
| bTracePath | bool | If true, traces along the arc to detect blocking hits against the specified object types. | — |
| ProjectileRadius | float | Radius of the simulated spherical projectile. | — |
| ObjectTypes | const TArray<TEnumAsByte<EObjectTypeQuery>>& | Object types to trace against. | — |
| bTraceComplex | bool | Whether to trace against complex collision geometry. | — |
| ActorsToIgnore | const TArray<AActor*>& | Actors to exclude from collision checks. | — |
| DrawDebugType | EDrawDebugTrace::Type | Controls debug visualization (none, one-frame, duration, persistent). | — |
| DrawDebugTime | float | Duration in seconds for debug lines when using the Duration draw type. | — |
| SimFrequency | float | Number of simulation steps per second; higher values give more accurate paths at greater cost. | 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 grenade arc against world static objects C++
FHitResult HitResult;
TArray<FVector> PathPositions;
FVector LastDest;
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes = { UEngineTypes::ConvertToObjectType(ECC_WorldStatic) };
TArray<AActor*> Ignored = { this };
bool bHit = UGameplayStatics::Blueprint_PredictProjectilePath_ByObjectType(
this, HitResult, PathPositions, LastDest,
GetActorLocation(), LaunchVelocity,
true, 10.f, ObjectTypes, false, Ignored,
EDrawDebugTrace::ForDuration, 1.f
); See Also
Tags
Version History
Introduced in: 4.15
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?