5#include "CoreMinimal.h"
8#include "CharacterGrabberComponent.generated.h"
25UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent))
31 UCharacterGrabberComponent();
33 UPROPERTY(BlueprintAssignable, Category="Grabber")
34 FOnPickupActor OnPickupActor;
36 UFUNCTION(BlueprintCallable, Category="Grabber")
37 void SetGrabbedComponent(const FVector&
Location, const FRotator& Rotation) const;
39 void SetThrowStrength(const
float Strength){ThrowStrength = Strength;};
40 UFUNCTION(BlueprintCallable, Category=
"Grabber")
41 UPrimitiveComponent* GetGrabbedComponent() const;
43 UFUNCTION(BlueprintPure, BlueprintCallable, Category="Grabber")
44 bool GetIsHoldingActor() const;
46 UFUNCTION(BlueprintCallable, Category="Grabber")
47 void GrabActor(const FHitResult& HitResult);
48 UFUNCTION(
Server, Reliable, Category="Grabber")
49 void Server_GrabActor(const FHitResult& HitResult);
51 UFUNCTION(BlueprintCallable, Category="Grabber")
52 void PickupActorFromInteraction();
54 UFUNCTION(
Server, Reliable, Category="Grabber")
57 UFUNCTION(
Server, Reliable, BlueprintCallable, Category="Grabber")
58 void Server_DropActor();
59 UFUNCTION(BlueprintCallable, Category="Grabber")
62 UFUNCTION(
Server, Reliable, BlueprintCallable, Category="Grabber")
63 void Server_ThrowActor(const
float ForceMultiplier = 1.0f);
64 UFUNCTION(BlueprintCallable, Category="Grabber")
65 void ThrowActor(const
float ForceMultiplier = 1.0f);
67 UFUNCTION(BlueprintCallable, Category="Grabber")
68 void SetGrabDistance(const
float Distance);
69 UFUNCTION(BlueprintPure, BlueprintCallable, Category="Grabber")
70 float GetGrabDistance()
const {
return GrabDistance;};
73 UFUNCTION(BlueprintCallable, Category=
"Grabber")
74 void RotateObjectXAxis(const
float Value);
75 UFUNCTION(BlueprintCallable, Category="Grabber")
76 void RotateObjectYAxis(const
float Value);
79 UFUNCTION(BlueprintCallable, Category="Grabber")
80 void SetGrabberRotationMode(const
bool bTurnOn);
82 UFUNCTION(BlueprintCallable, Category="Grabber")
85 UFUNCTION(BlueprintCallable, Category="Grabber")
86 void ZoomObject(const
float Value);
87 UFUNCTION(
Server, Reliable, Category="Grabber")
88 void Server_ZoomObject(const
float Value);
90 UFUNCTION(BlueprintCallable, Category="Grabber")
91 bool GetIsInRotationMode()
const {
return bRotationMode;};
93 FVector GetTargetLocation()
const {
return TargetLocation;};
94 FVector GetAttachPointLocation()
const
96 if(IsActive() ==
false){
return FVector::ZeroVector;}
97 if(AttachPoint ==
nullptr){LogDebugError(
"GetAttachPointLocation, AttachPoint");
return FVector::ZeroVector;}
98 return AttachPoint->GetComponentLocation();
102 virtual void BeginPlay()
override;
103 virtual void TickComponent(
float DeltaTime,
enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
override;
104 virtual void ComponentSetupComplete()
override;
105 virtual void ComponentDeactivated(UActorComponent* Component)
override;
107 UFUNCTION(
Server, Reliable, Category=
"Grabber")
108 void Server_PickupActor(const FName BoneName, const FVector
Location, const FRotator Rotation);
109 UFUNCTION(BlueprintCallable, Category="Grabber")
110 void PickupActor(const FName BoneName, const FVector
Location, const FRotator Rotation);
113 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
114 bool bLogTick = false;
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
116 bool bSetRotation = true;
117 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
118 bool bUseNormalTick = true;
119 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
120 bool bAddStartRotation = true;
121 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
122 bool bSetRotationZero = true;
123 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
124 bool bOverrideMass = false;
125 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging", meta=(EditCondition=bOverrideMass))
126 float NewMass = 0.5f;
127 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Debugging")
128 bool bShowTraceLocations = false;
131 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|
General")
132 float GrabDistanceAddition= -30.0f;
133 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|
General")
134 float GrabLocationOffset = 120.0f;
135 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|
General")
136 float GrabUpdateTick = 0.01f;
137 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|
General")
138 bool bUseCameraLocation = true;
139 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|
General")
140 bool bUsePlayerOffset = true;
141 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|
General")
142 bool bUsePlayerRotation = true;
146 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Physics")
147 float LinearDamping = 200.0f;
148 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Physics")
149 float LinearStiffness = 1750.0f;
150 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Physics")
151 float AngularDamping = 500.0f;
152 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Physics")
153 float AngularStiffness = 1500.0f;
154 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Physics")
155 float InterpolationSpeed = 1000.0f;
159 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Zoom")
160 float ZoomSpeed = 10.0f;
161 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Zoom")
162 float ZoomClampMin = 50.0f;
163 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Zoom")
164 float ZoomClampMax = 150.0f;
165 UPROPERTY(Replicated, EditAnywhere, BlueprintReadOnly, Category="Grabber|Zoom")
166 float ZoomValue = 150.0f;
167 float ZoomValueDefault = 0.0f;
169 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Rotate")
170 bool bUseRotateLerp = false;
171 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Rotate", meta=(ClampMin=0.0f, ClampMax=1.0f))
172 float SmoothAutoRotation = 0.4;
173 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Rotate")
174 float RotationModeSensitivity = 150.0f;
176 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Rotate")
177 bool bYRotationDisabled = false;
178 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Rotate")
179 bool bXRotationDisabled = false;
182 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Grabber|Snapping")
183 TEnumAsByte<ECollisionChannel> SnapTraceChannel;
189 FVector GetThrowForce(const
float Multiplier) const;
190 FRotator GetRotation() const;
191 FVector GetLocation() const;
193 UFUNCTION(
Server, Reliable, Category="Grabber")
194 void Server_SetGrabDistance(const
float Distance);
196 void SnapLineTrace();
197 void DrawSnapStatus(const FVector&
Location) const;
200 bool GetPhysicsComponent(const AActor* Actor);
201 bool GetPhysicsActor(AActor* Actor);
204 void OnRep_CanSnap();
207 UPROPERTY(Replicated, VisibleAnywhere, Category="Grabber|Status")
208 bool bHoldingActor = false;
209 UPROPERTY(Replicated, VisibleAnywhere, Category="Grabber|Status")
210 bool bRotationMode = false;
211 UPROPERTY(Replicated, VisibleAnywhere, Category="Grabber|Status")
212 float GrabDistance = 500.0f;
213 UPROPERTY(ReplicatedUsing=OnRep_CanSnap, VisibleAnywhere, Category="Grabber|Status")
214 bool bCanSnap = false;
218 UPROPERTY(VisibleAnywhere, Category="Grabber|Status")
219 FVector TargetLocation = FVector::ZeroVector;
220 UPROPERTY(VisibleAnywhere, Category="Grabber|Status")
221 FName TargetBone = NAME_None;
222 UPROPERTY(VisibleAnywhere, Category="Grabber|Status")
223 FRotator CurrentHeldRotation = FRotator::ZeroRotator;
224 UPROPERTY(VisibleAnywhere, Category="Grabber|Status")
225 FVector LastHeldLocation = FVector::ZeroVector;
227 UPROPERTY(VisibleAnywhere, Category="Grabber|Status")
228 float TraceDistanceMin = 10.0f;
230 FRotator PendingRotationDelta;
231 float RotationInputBufferTime = 0.0f;
232 const
float RotationApplyRate = 1.0f / 20.0f;
234 UFUNCTION(
Server, Unreliable)
235 void Server_ApplyRotationDelta(FRotator Delta);
236 void ApplyRotationDelta(const FRotator& Delta);
238 UPROPERTY(Replicated, VisibleAnywhere, Category="Grabber|Status|Components")
239 class UPrimitiveComponent* TargetComponent =
nullptr;
240 UPROPERTY(VisibleAnywhere, Category="Grabber|Status|Components")
241 class UPrimitiveComponent* TargetComponentAttach =
nullptr;
244 UPROPERTY(Replicated)
245 class UPhysicsHandleComponent* PhysicsHandleComponent;
246 UPROPERTY(Replicated)
247 class USceneComponent* AttachPoint =
nullptr;
249 float ThrowStrength = 500.0f;
252 FHitResult LastHitResult;
254 FTimerHandle GrabTickTimerHandle;
DECLARE_LOG_CATEGORY_EXTERN(LogGrabberComponent, Display, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPickupActor, bool, bPickedUp)
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition PhysicsPickup.h:21
Represents a character component that can be added to an actor.