Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/UGameplayStatics
Description
Returns a launch velocity need for a projectile to hit the TargetActor in TimeToTarget seconds based on the TargetActor's current velocity. This assumes the projectile is only accelerated by gravity (i.e. no outside forces), and that the TargetActor is moving at a constant velocity.
| Name | SuggestProjectileVelocity_MovingTarget |
| Type | function |
| Header File | /Engine/Source/Runtime/Engine/Classes/Kismet/GameplayStatics.h |
| Include Path | #include "Kismet/GameplayStatics.h" |
| Source | /Engine/Source/Runtime/Engine/Private/GameplayStatics.cpp |
UFUNCTION (BlueprintCallable, Category="Game",
DisplayName="Suggest Projectile Velocity Moving Target",
Meta=(WorldContext="WorldContextObject", AdvancedDisplay="DrawDebugType, DrawDebugTime, DrawDebugColor"))
static bool SuggestProjectileVelocity_MovingTarget
(
const UObject * WorldContextObject,
FVector & OutLaunchVelocity,
FVector ProjectileStartLocation,
AActor * TargetActor,
FVector TargetLocationOffset,
double GravityZOverride,
double TimeToTarget,
EDrawDebugTrace::Type DrawDebugType,
float DrawDebugTime,
FLinearColor DrawDebugColor
)
Parameters
| Name | Remarks |
|---|---|
| OutLaunchVelocity | The launch velocity returned from this calculation |
| ProjectileStartLocation | Location the projectile is launched from |
| TargetActor | Actor that the projectile should hit in TimeToTarget seconds |
| TargetLocationOffset | Offset to apply to the location the projectile is aiming for |
| GravityZOverride | Optional override of WorldGravityZ |
| TimeToTarget | Time (in seconds) between the projectile being launched and the projectile hitting the TargetActor - clamped to be at least 0.1 |