Documentation for the Unreal C++ Plugin
Loading...
Searching...
No Matches
BaseGrippableStoryActor.h
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "BaseStoryActor.h"
7#include "PixoVRHand.h"
8#include "Grippables/GrippableActor.h"
10#include "BaseGrippableStoryActor.generated.h"
11
13
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActorPositionReset, ABaseGrippableStoryActor*, GrippableStoryActor);
16DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDroppedActorDeleted, UClass*, DeletedClass);
17
21UENUM(BlueprintType)
22enum class EHandGripLogic : uint8
23{
24 AttachToHand UMETA("AttachToHand"),
25 AttachToHandWithCustomTransform UMETA("AttachToHandWithCustomTransform"),
26 CustomTransformAttachWithPhysics UMETA("CustomTransformAttachWithPhysics"),
27 OnlyOnGripEvent UMETA("TriggerOnlyOnGripEvent"),
28 NativeVRGripInterfaceSettings UMETA("NativeVRGripInterfaceSettings")
29};
30
34UCLASS(Blueprintable)
35class PIXOCORE_API ABaseGrippableStoryActor : public ABaseStoryActor, public IVRGripInterface,
37{
39
40public:
42
43 virtual void BeginPlay() override;
48 virtual void ObjectActivated_Implementation() override;
52 virtual void ObjectDeactivated_Implementation() override;
56 virtual void UpdateObjectHighlight_Implementation(bool Activate) override;
57
61 virtual void OnGrip_Implementation(UGripMotionControllerComponent* GrippingController,
62 const FBPActorGripInformation& GripInformation) override;
66 virtual void OnGripRelease_Implementation(UGripMotionControllerComponent* ReleasingController,
67 const FBPActorGripInformation& GripInformation,
68 bool bWasSocketed) override;
72 virtual void OnSecondaryGrip_Implementation(UGripMotionControllerComponent* GripOwningController,
73 USceneComponent* SecondaryGripComponent,
74 const FBPActorGripInformation& GripInformation) override;
78 virtual void OnSecondaryGripRelease_Implementation(UGripMotionControllerComponent* GripOwningController,
79 USceneComponent* ReleasingSecondaryGripComponent,
80 const FBPActorGripInformation& GripInformation) override;
84 virtual void IsHeld_Implementation(TArray<FBPGripPair>& HoldingControllers, bool& bIsHeld) override;
88 virtual void SetHeld_Implementation(UGripMotionControllerComponent* HoldingController, uint8 GripID,
89 bool bIsHeld) override;
94 virtual bool DenyGripping_Implementation(UGripMotionControllerComponent* GripInitiator = nullptr) override;
98 virtual EGripInterfaceTeleportBehavior TeleportBehavior_Implementation() override;
102 virtual bool SimulateOnDrop_Implementation() override;
106 virtual EGripCollisionType GetPrimaryGripType_Implementation(bool bIsSlot) override;
110 virtual ESecondaryGripType SecondaryGripType_Implementation() override;
114 virtual EGripMovementReplicationSettings GripMovementReplicationType_Implementation() override;
118 virtual EGripLateUpdateSettings GripLateUpdateSetting_Implementation() override;
122 virtual void GetGripStiffnessAndDamping_Implementation(float& GripStiffnessOut, float& GripDampingOut) override;
126 virtual FBPAdvGripSettings AdvancedGripSettings_Implementation() override;
130 virtual float GripBreakDistance_Implementation() override;
134 virtual void ClosestGripSlotInRange_Implementation(FVector WorldLocation, bool bSecondarySlot,
135 bool& bHadSlotInRange, FTransform& SlotWorldTransform,
136 FName& SlotName,
137 UGripMotionControllerComponent* CallingController = nullptr,
138 FName OverridePrefix = NAME_None) override;
142 virtual bool AllowsMultipleGrips_Implementation() override;
143
147 virtual bool IsGrabbingWrongActorActive_Implementation() override;
148
152 virtual void SendWrongGrabbingNotification_Implementation() override;
153
157 virtual FTransform GetObjectGrabTransform_Implementation(APixoVRHand* GrabbedHand) override;
158
159 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
160 FVROnGripSignature OnGripped;
161 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
162 FVROnDropSignature OnDropped;
163
164 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
165 FVROnGripSignature OnSecondaryGripAdded;
166
167 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
168 FVROnGripSignature OnSecondaryGripRemoved;
170 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
171 FBPInterfaceProperties VRGripInterfaceSettings;
172
178 UFUNCTION(BlueprintImplementableEvent, Category = "Grip Events")
179 void OnGrippedEvent(UGripMotionControllerComponent* GrippingController,
180 const FBPActorGripInformation& GripInformation);
187 UFUNCTION(BlueprintImplementableEvent, Category = "Grip Events")
188 void OnReleasedEvent(UGripMotionControllerComponent* ReleasingController,
189 const FBPActorGripInformation& GripInformation, bool bWasSocketed);
190
191 // Different grip behavior
196 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
197 void UpdateHandGripLogic(EHandGripLogic NewHandGripLogic);
203 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
204 void AttachToHandObject(UGripMotionControllerComponent* GrippingController,
205 const FBPActorGripInformation& GripInformation);
209 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
210 void DetachObjectFromHand();
211
215 virtual void GrabWithTwoHands_Implementation(UMotionControllerComponent* GrabbingController) override;
216 virtual void ReleaseTwoHands_Implementation(UMotionControllerComponent* ReleasingController) override;
217 virtual bool IsObjectHeldWithTwoHands_Implementation() override;
218 virtual void ResetTwoHandsHoldingFunctionality_Implementation() override;
219 virtual void EnableOnePressDetach_Implementation(bool Enable) override;
220
221 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Two Hands Grip")
222 bool ObjectHeldWithTwoHands = false;
223
224 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GrippableObject")
225 EHandGripLogic HandGripLogic;
226 UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "GrippableObject")
227 APixoVRHand* CurrentHoldingHand;
228 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
229 FTransform ObjectTransformInLeftHand;
230 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
231 FTransform ObjectTransformInRightHand;
232
233 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
234 UStaticMeshComponent* StaticMeshComponent;
235
236 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
237 bool bGripSoundsEnabled;
238
239 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta = (EditCondition = "bGripSoundsEnabled", EditConditionHides))
240 USoundCue* GripSoundCue;
241
242 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
243 bool bReleaseSoundsEnabled;
244
245 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta = (EditCondition = "bReleaseSoundsEnabled", EditConditionHides))
246 USoundCue* ReleaseSoundCue;
247
248 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
249 bool bFeedbackEnabled;
250
251 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFeedbackEnabled", EditConditionHides))
252 float HapticDuration;
253
254 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFeedbackEnabled", EditConditionHides))
255 float HapticStrength;
256
257 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GrippableObject")
258 bool StoryActivationAffectsDenyGripping { true };
259
260 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GrippableObject")
261 bool bActivateLocationResetAfterDrop { false };
262
263 UPROPERTY(BlueprintReadWrite, Category = "GrippableObject")
264 bool bCanResetPosition { true };
265
266 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GrippableObject")
267 bool bDestroyActorAfterFailedDrop { false };
268
269 UPROPERTY(BlueprintReadOnly, Category = "GrippableObject")
270 FTransform ResetTransform;
271
272 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
273 float PositionResetCheckRate { 0.1f };
274
275 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
276 float PositionResetMaximumDelay { 5.0f };
277
278 UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
279 FOnActorStopped OnActorStoppedDelegate;
280
281 UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
282 FOnActorStopped OnActorPositionResetDelegate;
283
284 UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
285 FOnDroppedActorDeleted OnDroppedActorDeleted;
286
290 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
291 void ResetPosition();
292
296 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
297 void StartPositionResetTimer();
298
302 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
303 void StopPositionResetTimer();
304
308 UFUNCTION()
309 void CheckPositionResetConditions();
310
311private:
312
313 bool bSaveResetTransformOnGrip { true };
314
315 float TimeSinceResetTimerStarted { 0.0f };
317 FTimerHandle PositionResetTimer;
318
323 void PlayHapticFeedbackEffect(UGripMotionControllerComponent* GripMotionControllerComponent) const;
324
325 void PlayGripSound() const;
326
327 void PlayReleaseSound() const;
328
329 void TwoHandGrab();
330 void HandCrossDetection(float CurrentPitch, float RightLeftHandVPitch);
331 bool CrossDetected;
332 bool CrossChanged;
333 float PitchBeforeCross = 0;
334 float MoveBackPitchDelta = 0;
335 float ResultedPitch = 0;
336 TWeakObjectPtr<APixoVRHand> PixoVRHandLeft;
337 TWeakObjectPtr<APixoVRHand> PixoVRHandRight;
338 float TwoHandZAxisValue = 0.0;
339 FTimerHandle TwoHandTimer;
340 TWeakObjectPtr<UMotionControllerComponent> TwoHandMainGrabController;
342};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActorStopped, ABaseGrippableStoryActor *, GrippableStoryActor)
EHandGripLogic
Enum representing the different hand grip logic options.
@ OnlyOnGripEvent
@ AttachToHandWithCustomTransform
@ NativeVRGripInterfaceSettings
@ AttachToHand
@ CustomTransformAttachWithPhysics
Base class for grippable story actors that can be interacted with hands.
bool EnableOnePressDetach
TWeakObjectPtr< UMotionControllerComponent > TwoHandMainGrabController
TWeakObjectPtr< APixoVRHand > PixoVRHandLeft
FOnDroppedActorDeleted OnDroppedActorDeleted
UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
float HapticStrength
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFee...
FVROnGripSignature OnSecondaryGripAdded
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
FTransform ResetTransform
UPROPERTY(BlueprintReadOnly, Category = "GrippableObject")
bool CrossChanged
EHandGripLogic HandGripLogic
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GrippableObject")
FTransform ObjectTransformInRightHand
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
FVROnGripSignature OnSecondaryGripRemoved
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
float HapticDuration
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFee...
bool bGripSoundsEnabled
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
USoundCue * ReleaseSoundCue
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta = (EditCondition = "bR...
FVROnDropSignature OnDropped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
UStaticMeshComponent * StaticMeshComponent
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
FVROnGripSignature OnGripped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
bool CrossDetected
void OnGrippedEvent(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation)
Event triggered when the object is gripped.
TWeakObjectPtr< APixoVRHand > PixoVRHandRight
USoundCue * GripSoundCue
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta = (EditCondition = "bG...
APixoVRHand * CurrentHoldingHand
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "GrippableObject")
FTimerHandle PositionResetTimer
Internal timer for checking object's conditions for position reset.
FBPInterfaceProperties VRGripInterfaceSettings
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
FOnActorStopped OnActorStoppedDelegate
UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
FOnActorStopped OnActorPositionResetDelegate
UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
FTransform ObjectTransformInLeftHand
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
GENERATED_BODY()
bool bFeedbackEnabled
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
bool bReleaseSoundsEnabled
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
void OnReleasedEvent(UGripMotionControllerComponent *ReleasingController, const FBPActorGripInformation &GripInformation, bool bWasSocketed)
Event triggered when the object is released from the grip.
FTimerHandle TwoHandTimer
Base class for story actors.
GENERATED_BODY()
virtual void BeginPlay() override
APixoVRHand is an actor class that represents a hand in the VR environment.
Definition PixoVRHand.h:99
Interface for grip response animation functionality.
void EnableOnePressDetach(bool Enable)
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Grip Behavior|Two Hands")