A Demo Project for the UnrealEngineSDK
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"
10#include "BaseGrippableStoryActor.generated.h"
11
13
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActorPositionReset, ABaseGrippableStoryActor*, GrippableStoryActor);
16
20UENUM(BlueprintType)
21enum class EHandGripLogic : uint8
22{
23 AttachToHand UMETA("AttachToHand"),
24 AttachToHandWithCustomTransform UMETA("AttachToHandWithCustomTransform"),
25 OnlyOnGripEvent UMETA("TriggerOnlyOnGripEvent")
26};
27
31UCLASS(Blueprintable)
32class PIXOCORE_API ABaseGrippableStoryActor : public ABaseStoryActor, public IVRGripInterface,
34{
36
37public:
39
40 virtual void BeginPlay() override;
45 virtual void ObjectActivated_Implementation() override;
49 virtual void ObjectDeactivated_Implementation() override;
53 virtual void UpdateObjectHighlight_Implementation(bool Activate) override;
54
58 virtual void OnGrip_Implementation(UGripMotionControllerComponent* GrippingController,
59 const FBPActorGripInformation& GripInformation) override;
63 virtual void OnGripRelease_Implementation(UGripMotionControllerComponent* ReleasingController,
64 const FBPActorGripInformation& GripInformation,
65 bool bWasSocketed) override;
69 virtual void OnSecondaryGrip_Implementation(UGripMotionControllerComponent* GripOwningController,
70 USceneComponent* SecondaryGripComponent,
71 const FBPActorGripInformation& GripInformation) override;
75 virtual void OnSecondaryGripRelease_Implementation(UGripMotionControllerComponent* GripOwningController,
76 USceneComponent* ReleasingSecondaryGripComponent,
77 const FBPActorGripInformation& GripInformation) override;
81 virtual void IsHeld_Implementation(TArray<FBPGripPair>& HoldingControllers, bool& bIsHeld) override;
85 virtual void SetHeld_Implementation(UGripMotionControllerComponent* HoldingController, uint8 GripID,
86 bool bIsHeld) override;
91 virtual bool DenyGripping_Implementation(UGripMotionControllerComponent* GripInitiator = nullptr) override;
95 virtual EGripInterfaceTeleportBehavior TeleportBehavior_Implementation() override;
99 virtual bool SimulateOnDrop_Implementation() override;
103 virtual EGripCollisionType GetPrimaryGripType_Implementation(bool bIsSlot) override;
107 virtual ESecondaryGripType SecondaryGripType_Implementation() override;
111 virtual EGripMovementReplicationSettings GripMovementReplicationType_Implementation() override;
115 virtual EGripLateUpdateSettings GripLateUpdateSetting_Implementation() override;
119 virtual void GetGripStiffnessAndDamping_Implementation(float& GripStiffnessOut, float& GripDampingOut) override;
123 virtual FBPAdvGripSettings AdvancedGripSettings_Implementation() override;
127 virtual float GripBreakDistance_Implementation() override;
131 virtual void ClosestGripSlotInRange_Implementation(FVector WorldLocation, bool bSecondarySlot,
132 bool& bHadSlotInRange, FTransform& SlotWorldTransform,
133 FName& SlotName,
134 UGripMotionControllerComponent* CallingController = nullptr,
135 FName OverridePrefix = NAME_None) override;
139 virtual bool AllowsMultipleGrips_Implementation() override;
140
141 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
142 FVROnGripSignature OnGripped;
143 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
144 FVROnDropSignature OnDropped;
145
146 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
147 FVROnGripSignature OnSecondaryGripAdded;
148
149 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
150 FVROnGripSignature OnSecondaryGripRemoved;
152 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
153 FBPInterfaceProperties VRGripInterfaceSettings;
154
160 UFUNCTION(BlueprintImplementableEvent, Category = "Grip Events")
161 void OnGrippedEvent(UGripMotionControllerComponent* GrippingController,
162 const FBPActorGripInformation& GripInformation);
169 UFUNCTION(BlueprintImplementableEvent, Category = "Grip Events")
170 void OnReleasedEvent(UGripMotionControllerComponent* ReleasingController,
171 const FBPActorGripInformation& GripInformation, bool bWasSocketed);
172
173 // Different grip behavior
178 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
179 void UpdateHandGripLogic(EHandGripLogic NewHandGripLogic);
185 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
186 void AttachToHandObject(UGripMotionControllerComponent* GrippingController,
187 const FBPActorGripInformation& GripInformation);
191 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
192 void DetachObjectFromHand();
193
194 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GrippableObject")
195 EHandGripLogic HandGripLogic;
196 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GrippableObject", meta=(EditCondition = "HandGripLogic == EHandGripLogic::AttachToHandWithCustomTransform", EditConditionHides))
197 bool bDisablePhysicsOnCustomTransformAttach { true };
198 UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "GrippableObject")
199 APixoVRHand* CurrentHoldingHand;
200 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
201 FTransform ObjectTransformInLeftHand;
202 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
203 FTransform ObjectTransformInRightHand;
204
205 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
206 UStaticMeshComponent* StaticMeshComponent;
207
208 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect")
209 bool bFeedbackEnabled;
210
211 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFeedbackEnabled", EditConditionHides))
212 float HapticDuration;
213
214 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFeedbackEnabled", EditConditionHides))
215 float HapticStrength;
216
217 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "GrippableObject")
218 bool bActivateLocationResetAfterDrop { false };
219
220 UPROPERTY(BlueprintReadWrite, Category = "GrippableObject")
221 bool bCanResetPosition { true };
222
223 UPROPERTY(BlueprintReadOnly, Category = "GrippableObject")
224 FTransform ResetTransform;
225
226 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GrippableObject")
227 float VelocityCheckRate { 0.1f };
228
229 UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
230 FOnActorStopped OnActorStoppedDelegate;
231
232 UPROPERTY(BlueprintReadWrite, BlueprintCallable, BlueprintAssignable)
233 FOnActorStopped OnActorPositionResetDelegate;
234
238 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
239 void ResetPosition();
240
244 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
245 void StartVelocityCheckTimer();
246
250 UFUNCTION(BlueprintCallable, Category = "GrippableObject")
251 void StopVelocityCheckTimer();
252
256 UFUNCTION()
257 void CheckVelocity();
258
259private:
261 bool bSaveResetTransformOnGrip { true };
262
263 FTimerHandle VelocityCheckTimer;
264
269 void PlayHapticFeedbackEffect(UGripMotionControllerComponent* GripMotionControllerComponent) const;
270};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActorStopped, ABaseGrippableStoryActor *, GrippableStoryActor)
EHandGripLogic
Enum representing the different hand grip logic options.
@ OnlyOnGripEvent
@ AttachToHandWithCustomTransform
@ AttachToHand
EGripMovementReplicationSettings
UENUM(Blueprintable)
ESecondaryGripType
UENUM(Blueprintable)
EGripCollisionType
UENUM(Blueprintable)
EGripLateUpdateSettings
UENUM(Blueprintable)
EGripInterfaceTeleportBehavior
UENUM(Blueprintable)
Base class for grippable story actors that can be interacted with hands.
FTimerHandle VelocityCheckTimer
Internal timer for checking object's velocity in a given time.
float HapticStrength
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Feedback Effect", meta=(EditCondition = "bFee...
FVROnGripSignature OnSecondaryGripAdded
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
FTransform ResetTransform
UPROPERTY(BlueprintReadOnly, Category = "GrippableObject")
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...
FVROnDropSignature OnDropped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
UStaticMeshComponent * StaticMeshComponent
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Components")
FVROnGripSignature OnGripped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
void OnGrippedEvent(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation)
Event triggered when the object is gripped.
APixoVRHand * CurrentHoldingHand
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category = "GrippableObject")
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")
void OnReleasedEvent(UGripMotionControllerComponent *ReleasingController, const FBPActorGripInformation &GripInformation, bool bWasSocketed)
Event triggered when the object is released from the grip.
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.
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController)
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")