UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GameplayStaticsTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
5#include "Engine/HitResult.h"
6#include "GameplayStaticsTypes.generated.h"
7
8// Trace option to SuggestProjectileVelocity functions.
9UENUM()
19
20// Input parameters to PredictProjectilePath functions.
21USTRUCT(BlueprintType)
23{
25
26 // Location of the start of the trace.
27 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams)
28 FVector StartLocation;
29
30 // Initial launch velocity at the start of the trace.
31 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams)
32 FVector LaunchVelocity;
33
34 // Whether to trace along the path looking for blocking collision and stopping at the first hit.
35 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams)
36 bool bTraceWithCollision;
37
38 // Projectile radius, used when tracing for collision. If <= 0, a line trace is used instead.
39 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams)
40 float ProjectileRadius;
41
42 // Maximum simulation time for the virtual projectile.
43 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams)
44 float MaxSimTime;
45
46 // Whether or not to use TraceChannel, if tracing with collision.
47 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = PredictProjectilePathParams)
48 bool bTraceWithChannel;
49
50 // Trace channel to use, if tracing with collision.
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = PredictProjectilePathParams)
53
54 // Object type to use, if tracing with collision.
55 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
57
58 // Actors to ignore when tracing with collision.
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
60 TArray<TObjectPtr<AActor>> ActorsToIgnore;
61
62 // Determines size of each sub-step in the simulation (chopping up MaxSimTime). Recommended between 10 to 30 depending on desired quality versus performance.
63 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
64 float SimFrequency;
65
66 // Optional override of Gravity (if 0, uses WorldGravityZ).
67 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
68 float OverrideGravityZ;
69
70 // Debug drawing duration option.
71 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
72 TEnumAsByte<EDrawDebugTrace::Type> DrawDebugType;
73
74 // Duration of debug lines (only relevant for DrawDebugType::Duration)
75 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
76 float DrawDebugTime;
77
78 // Trace against complex collision (triangles rather than simple primitives) if tracing with collision.
79 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PredictProjectilePathParams, AdvancedDisplay)
81
82 // Empty constructor. You typically want to use another one that enforces thought about reasonable values for the most important parameters.
87
88 // Constructor defaulting to no collision.
93
94 // Constructor to use collision with an ObjectType. Additional types can be added to the array. TraceWithCollision is set to true automatically.
96 {
98 ObjectTypes.Add(ObjectType);
99 bTraceWithChannel = false;
100 if (ActorToIgnore)
101 {
102 ActorsToIgnore.Add(ActorToIgnore);
103 }
104 }
105
106 // Constructor to use collision with a trace channel. TraceWithCollision is set to true automatically.
116
117private:
118
120 {
121 StartLocation = InStartLocation;
122 LaunchVelocity = InLaunchVelocity;
123 bTraceWithCollision = InTraceWithCollision;
124 ProjectileRadius = InProjectileRadius;
125 MaxSimTime = InMaxSimTime;
126 SimFrequency = 20.f;
127 OverrideGravityZ = 0.f;
128 DrawDebugTime = 1.f;
129 bTraceWithChannel = true;
130 TraceChannel = ECC_WorldStatic;
131 DrawDebugType = EDrawDebugTrace::None;
132 bTraceComplex = false;
133 }
134};
135
136
137// Data about a single point in a projectile path trace.
138USTRUCT(BlueprintType)
140{
142
143 // Location of this point
144 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=PredictProjectilePathPointData)
145 FVector Location;
146
147 // Velocity at this point
148 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=PredictProjectilePathPointData)
150
151 // Elapsed time at this point from the start of the trace.
152 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=PredictProjectilePathPointData)
153 float Time;
154
156 : Location(ForceInitToZero)
158 , Time(0.f)
159 {
160 }
161
168
169 void Reset()
170 {
172 }
173
175 {
176 Location = InLocation;
178 Time = InTime;
179 }
180};
181
182
183// Container for the result of a projectile path trace (using PredictProjectilePath).
184USTRUCT(BlueprintType)
186{
188
189 // Info for each point on the path.
190 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=PredictProjectilePathResult)
192
193 // Info on the last point we tried to trace to, which may have been beyond the final hit.
194 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=PredictProjectilePathResult)
196
197 // Hit along the trace, if tracing with collision was enabled.
198 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=PredictProjectilePathResult)
199 FHitResult HitResult;
200
202 {
203 PathData.Reset(ReserveSize);
204 LastTraceDestination = FPredictProjectilePathPointData();
205 HitResult.Init();
206 }
207
208 void AddPoint(FVector Location, FVector Velocity, float Time)
209 {
210 PathData.Emplace(FPredictProjectilePathPointData(Location, Velocity, Time));
211 }
212};
213
@ ForceInitToZero
Definition CoreMiscDefines.h:156
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EObjectTypeQuery
Definition EngineTypes.h:1160
ECollisionChannel
Definition EngineTypes.h:1088
#define FVector
Definition IOSSystemIncludes.h:8
void Init()
Definition LockFreeList.h:4
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
const bool bTraceComplex
Definition PhysicsInterfaceUtils.h:19
Definition Actor.h:257
Definition Array.h:670
Definition EnumAsByte.h:22
Definition KismetSystemLibrary.h:37
@ None
Definition KismetSystemLibrary.h:40
Definition GameplayStaticsTypes.h:11
Type
Definition GameplayStaticsTypes.h:13
@ DoNotTrace
Definition GameplayStaticsTypes.h:14
@ TraceFullPath
Definition GameplayStaticsTypes.h:15
@ OnlyTraceWhileAscending
Definition GameplayStaticsTypes.h:16
Definition HitResult.h:21
void Reset(float InTime=1.f, bool bPreserveTraceData=true)
Definition HitResult.h:197
void Init()
Definition HitResult.h:174
Definition GameplayStaticsTypes.h:23
FPredictProjectilePathParams(float InProjectileRadius, FVector InStartLocation, FVector InLaunchVelocity, float InMaxSimTime, EObjectTypeQuery ObjectType, AActor *ActorToIgnore=nullptr)
Definition GameplayStaticsTypes.h:95
FPredictProjectilePathParams(float InProjectileRadius, FVector InStartLocation, FVector InLaunchVelocity, float InMaxSimTime, ECollisionChannel InTraceChannel, AActor *ActorToIgnore=nullptr)
Definition GameplayStaticsTypes.h:107
FPredictProjectilePathParams(float InProjectileRadius, FVector InStartLocation, FVector InLaunchVelocity, float InMaxSimTime)
Definition GameplayStaticsTypes.h:89
Definition GameplayStaticsTypes.h:140
void Set(FVector InLocation, FVector InVelocity, float InTime)
Definition GameplayStaticsTypes.h:174
FPredictProjectilePathPointData(FVector InLocation, FVector InVelocity, float InTime)
Definition GameplayStaticsTypes.h:162
void Reset()
Definition GameplayStaticsTypes.h:169
Definition GameplayStaticsTypes.h:186
void AddPoint(FVector Location, FVector Velocity, float Time)
Definition GameplayStaticsTypes.h:208
Definition ObjectPtr.h:488
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
static CORE_API const TVector< double > ForwardVector
Definition Vector.h:91