Space Plunder
Loading...
Searching...
No Matches
AimAssistComponent.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
9#include "AimAssistComponent.generated.h"
10
11// For Players Controllers Only
12
13
14
23UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent) )
24class INTERACTION_API UAimAssistComponent : public UPlayerControllerComponent
25{
26 GENERATED_BODY()
27
28public:
30
32 virtual float CameraMovedUp(const float Value);
34 virtual float CameraMovedRight(const float Value);
35
36 UFUNCTION(BlueprintCallable, Category="Aim Assist")
37 void SetIsAiming(const bool bValue);
38
39 UFUNCTION(BlueprintCallable, Category="Aim Assist")
40 int32 GetAimAssistLevel() const;
41 UFUNCTION(BlueprintCallable, Category="Aim Assist")
42 void SetAimAssistLevel(const int32 Value);
43
45 UFUNCTION(BlueprintCallable, Category="Aim Assist")
46 void ClearTargets();
47
48 // virtual void ComponentSetup() override;
49
50#if WITH_GAMEPLAY_DEBUGGER
52 FAimAssist GetAimAssistData() const {return AimAssistData;}
53 TArray<FAimAssistHit> GetCurrentTargets() const {return Targets;};
54 int32 GetCurrentTarget() const {return CurrentTarget;};
55 float GetCameraUp() const {return CurrentCameraUp;};
56 float GetCameraRight() const {return CurrentCameraRight;};
57
58 void SetShowAimTraces(const bool bValue){bShowAimTraces = bValue;};
59
60#endif
61
62
63protected:
64 virtual void BeginPlay() override;
65
66 virtual void ComponentSetupComplete() override;
67
68 UFUNCTION(BlueprintCallable, Category="Aim Assist")
69 void StartSphereTrace();
70 UFUNCTION(BlueprintCallable, Category="Aim Assist")
71 void StopSphereTrace();
72
73 UFUNCTION(BlueprintCallable, Category="Aim Assist")
74 void TraceForward();
75
76 UFUNCTION(BlueprintCallable, Category="Aim Assist")
77 void ApplyRotation(const FRotator& TargetRotation) const;
78
79 UFUNCTION(BlueprintCallable, Category="Aim Assist")
80 float CalculateLerp(const FAimAssistHit& CurrentAimTarget) const;
81
82 UFUNCTION(BlueprintCallable, Category="Aim Assist")
83 TArray<FAimAssistHit> SphereTrace() const;
84
85
87 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist")
88 bool bDoesTraceTick = true;
89 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist")
90 bool bOnlyTickOnCameraMovement = true;
91 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist")
92 bool bDelayTraceEnd = false;
93
95 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist")
96 bool bOnlyOnSameCameraDirection = true;
97
98
100 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist")
101 float TraceTickRate = 0.1f;
102 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist")
103 float TraceDelay = 0.5f;
104
105 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aim Assist|Debugging")
106 float DebugTraceTime = 0.5f;
107 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Aim Assist")
108 FAimAssist AimAssistData;
109
110 UFUNCTION(BlueprintCallable, Category="Aim Assist")
111 bool GetCurrentAimTarget(FAimAssistHit& CurrentAimTarget);
112
113 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Aim Assist")
114 TArray<FAimAssistHit> Targets;
115 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Aim Assist")
116 int32 CurrentTarget = -1;
117
118 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Aim Assist|Camera")
119 bool bMovingAxis = false;
120 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Aim Assist|Camera")
121 float CurrentCameraUp = 0.0f;
122 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Aim Assist|Camera")
123 float CurrentCameraRight = 0.0f;
124
125 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Aim Assist|Camera")
126 bool bAiming = false;
127 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Aim Assist")
128 int32 AimAssistLevel = 1;
129
130 // float CalculateAxisModifier();
131 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
132 float CalculateSpeedModifier() const;
134 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
135 float CalculateDistance2D(const FVector& TargetLocation) const;
137 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
138 float CalculateDistance2DModifier(const float Distance2D) const;
139
141 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
142 float CalculateDistance2DAxisModifier(const float Distance2D) const;
143
144 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
145 float CalculateAimModifier() const;
146
147 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
148 float CalculateHitScore(const FHitResult& HitResult) const;
150 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
151 float CalculateDistanceModifier(const float Distance) const;
156 UFUNCTION(BlueprintCallable, Category="Aim Assist|Modifiers")
157 float CalculateAxisModifier() const;
158
159private:
160 // void HandleCameraMovement();
161 // void ResetCameraMovement();
162 void DelayTraceEnd(const float Modifier = 1.0f);
163
164 void TraceEnded();
165
166
167 bool bTracing = false;
168
170 bool CheckCanAimAssist();
172 void ProcessNewTargets(TArray<FAimAssistHit>& NewHits);
173
174 int32 SelectBestTarget() const;
175
177 void CameraUpInputStopped();
179 void CameraRightInputStopped();
181 void CheckMovingAxis();
182
183
184 FVector2D GetScreenLocation(const FVector& Location) const;
185 float GetNormalizedDistanceFromCenter(const FVector2D& ScreenPosition) const;
186
188 FTimerHandle CameraUpTimerHandle;
189 FTimerHandle CameraRightTimerHandle;
190
192 FTimerHandle SphereTraceTimerHandle;
193
194 bool bCameraMovement = false;
195 FTimerHandle CameraMovedTimerHandle;
196
197 FTimerHandle CameraResetTimerHandle;
198
199 FTimerHandle TracingTimerHandle;
200
201 bool bShowAimTraces = false;
202
203
204
205
206
207};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
This class provides aim assist functionality for player controllers in a game.
Represents an aim assist hit.
Definition InteractionData.h:187
Structure representing the parameters for aim assist in a game.
Definition InteractionData.h:264