UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ProjectileMovementComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
6#include "CoreMinimal.h"
7#include "Engine/HitResult.h"
8#endif // UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
11#include "ProjectileMovementComponent.generated.h"
12
13struct FHitResult;
14
26UCLASS(ClassGroup=Movement, meta=(BlueprintSpawnableComponent), ShowCategories=(Velocity), MinimalAPI)
28{
30
33
35 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Projectile)
36 float InitialSpeed;
37
39 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Projectile)
40 float MaxSpeed;
41
43 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Projectile)
45
47 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Projectile, meta = (EditCondition = "bRotationFollowsVelocity"))
49
51 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileBounces)
53
58 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Projectile)
60
67 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileSimulation)
68 uint8 bForceSubStepping:1;
69
73 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileSimulation)
74 uint8 bSimulationEnabled:1;
75
80 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileSimulation)
82
87 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Homing)
89
95 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileBounces)
97
101 UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category=ProjectileBounces)
103
110 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation)
112
119 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation)
120 uint8 bInterpRotation:1;
121
126 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation)
128
134
139
140public:
141
146 UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category=ProjectileInterpolation)
148
153 UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category=ProjectileInterpolation)
155
157 UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category=ProjectileBounces)
158 float PreviousHitTime;
159
161 UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category=ProjectileBounces)
163
165 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Projectile)
167
169 UPROPERTY()
170 float Buoyancy;
171
176 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileBounces, meta=(ClampMin="0", UIMin="0"))
177 float Bounciness;
178
186 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileBounces, meta=(ClampMin="0", UIMin="0"))
187 float Friction;
188
194 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileBounces)
196
201 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileBounces, AdvancedDisplay, meta=(ClampMin="0", UIMin="0", ClampMax="1", UIMax="1"))
203
207 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement")
209
211 UPROPERTY(BlueprintAssignable)
213
215 UPROPERTY(BlueprintAssignable)
217
219 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Homing)
221
226 UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category=Homing)
228
230 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement")
232
233 //Begin UActorComponent Interface
234 ENGINE_API virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
236 //End UActorComponent Interface
237
238 //Begin UMovementComponent Interface
239 virtual float GetMaxSpeed() const override { return MaxSpeed; }
240 ENGINE_API virtual void InitializeComponent() override;
241 ENGINE_API virtual void UpdateTickRegistration() override;
242 //End UMovementComponent Interface
243
248 ENGINE_API virtual bool CheckStillInWorld();
249
251 float GetBuoyancy() const { return Buoyancy; };
252
253 bool ShouldApplyGravity() const { return ProjectileGravityScale != 0.f; }
254
263 ENGINE_API virtual FVector ComputeVelocity(FVector InitialVelocity, float DeltaTime) const;
264
266 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement")
267 ENGINE_API virtual void StopSimulating(const FHitResult& HitResult);
268
269 bool HasStoppedSimulation() { return (UpdatedComponent == nullptr) || (IsActive() == false); }
270
281 ENGINE_API float GetSimulationTimeStep(float RemainingTime, int32 Iterations) const;
282
289 ENGINE_API virtual bool ShouldUseSubStepping() const;
290
298 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin="0.0166", ClampMax="0.50", UIMin="0.0166", UIMax="0.50"), Category=ProjectileSimulation)
299 float MaxSimulationTimeStep;
300
308 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin="1", ClampMax="25", UIMin="1", UIMax="25"), Category=ProjectileSimulation)
309 int32 MaxSimulationIterations;
310
314 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin="0", ClampMax="4", UIMin="0", UIMax="4"), Category=ProjectileSimulation)
316
323 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement|Interpolation")
325
329 ENGINE_API USceneComponent* GetInterpolatedComponent() const;
330
335 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement|Interpolation")
336 ENGINE_API virtual void MoveInterpolationTarget(const FVector& NewLocation, const FRotator& NewRotation);
337
341 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement|Interpolation")
342 ENGINE_API virtual void ResetInterpolation();
343
349 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, meta=(ClampMin="0"))
350 float InterpLocationTime;
351
357 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, meta=(ClampMin="0"))
358 float InterpRotationTime;
359
363 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, meta=(ClampMin="0"))
365
370 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, meta=(ClampMin="0"))
372
376 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, AdvancedDisplay)
378
382 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, AdvancedDisplay)
384
388 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, AdvancedDisplay, meta=(ClampMin="0", UIMin="0"))
390
394 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ProjectileInterpolation, AdvancedDisplay, meta=(ClampMin="0", UIMin="0"))
396
400 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement|Interpolation")
402
403protected:
404
409 ENGINE_API bool UpdateThrottleInterpolation(float DeltaTime, USceneComponent* InterpComponent);
410
416 ENGINE_API virtual int32 ComputeThrottleInterpolationMaxFrames(float DeltaTime, USceneComponent* InterpComponent);
417
421 ENGINE_API virtual void ResetThrottleInterpolation(float DeltaTime);
422
423 // Enum indicating how simulation should proceed after HandleBlockingHit() is called.
424 enum class EHandleBlockingHitResult
425 {
426 Deflect,
429 Abort,
430 };
431
446
452 ENGINE_API virtual void HandleImpact(const FHitResult& Hit, float TimeSlice=0.f, const FVector& MoveDelta = FVector::ZeroVector) override;
453
465 ENGINE_API virtual bool HandleDeflection(FHitResult& Hit, const FVector& OldVelocity, const uint32 NumBounces, float& SubTickTimeRemaining);
466
475 ENGINE_API virtual bool HandleSliding(FHitResult& Hit, float& SubTickTimeRemaining);
476
478 ENGINE_API virtual FVector ComputeBounceResult(const FHitResult& Hit, float TimeSlice, const FVector& MoveDelta);
479
480public:
481
483 UFUNCTION(BlueprintCallable, Category="Game|Components|ProjectileMovement")
484 ENGINE_API FVector LimitVelocity(FVector NewVelocity) const;
485
487 ENGINE_API virtual FVector ComputeMoveDelta(const FVector& InVelocity, float DeltaTime) const;
488
490 ENGINE_API virtual FVector ComputeAcceleration(const FVector& InVelocity, float DeltaTime) const;
491
494
497
499 FVector GetPendingForce() const { return PendingForce; }
500
503
504protected:
505
506 // Double-buffer of pending force so that updates can use the accumulated value and reset the data so other AddForce() calls work correctly.
507 // Also prevents accumulation over frames where the update aborts for whatever reason, and works with substepping movement.
509
510 ENGINE_API virtual void TickInterpolation(float DeltaTime);
511
517
518private:
519
520 // Pending force for next tick.
522
523public:
525 ENGINE_API virtual float GetGravityZ() const override;
526
527protected:
529 static ENGINE_API const float MIN_TICK_TIME;
530};
531
532
533
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
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param1Name, Param2Type, Param2Name)
Definition DelegateCombinations.h:62
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:53
ELevelTick
Definition EngineBaseTypes.h:70
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
bool IsActive() const
Definition ActorComponent.h:590
Definition MovementComponent.h:71
virtual ENGINE_API void HandleImpact(const FHitResult &Hit, float TimeSlice=0.f, const FVector &MoveDelta=FVector::ZeroVector)
Definition MovementComponent.cpp:377
virtual ENGINE_API float GetGravityZ() const
Definition MovementComponent.cpp:371
virtual ENGINE_API void InitializeComponent() override
Definition MovementComponent.cpp:111
virtual ENGINE_API void UpdateTickRegistration()
Definition MovementComponent.cpp:192
Definition EngineBaseTypes.h:571
Definition HitResult.h:21
static constexpr UE_FORCEINLINE_HINT T Square(const T A)
Definition UnrealMathUtility.h:578
Definition WeakObjectPtrTemplates.h:25
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
T SizeSquared() const
Definition Vector.h:1728