implement an optional feature in order to automatically stop all haptics on the end play event
This commit is contained in:
@@ -210,6 +210,8 @@ USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& Objec
|
||||
|
||||
bRight = true;
|
||||
|
||||
bAutoStopAllHapticsOnEndPlay = true;
|
||||
|
||||
GrabSocketName = FName{TEXT("GrabPoint")};
|
||||
|
||||
DefaultFingertipsGrabColliderSize = FVector{0.08f, 0.08f, 0.08f};
|
||||
@@ -330,6 +332,11 @@ void USGVirtualHandComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
{
|
||||
Super::EndPlay(EndPlayReason);
|
||||
|
||||
if (IsValid(Glove) && AutoStopsAllHapticsOnEndPlay())
|
||||
{
|
||||
Glove->StopHaptics();
|
||||
}
|
||||
|
||||
(void) Pimpl->UninitializeBackend();
|
||||
}
|
||||
|
||||
@@ -624,11 +631,6 @@ bool USGVirtualHandComponent::FImpl::InitializeBackend() const
|
||||
|
||||
bool USGVirtualHandComponent::FImpl::UninitializeBackend() const
|
||||
{
|
||||
if (IsValid(Owner->Glove))
|
||||
{
|
||||
Owner->Glove->StopHaptics();
|
||||
}
|
||||
|
||||
// NOTE
|
||||
// In Editor builds we should be avoiding dispose, since stopping the game in PIE mode, causes the virtual-hand
|
||||
// to disappear in the editor as the plugin won't be able to retrieve the glove status anymore.
|
||||
|
||||
@@ -84,6 +84,9 @@ private:
|
||||
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
|
||||
uint8 bRight : 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="SenseGlove | Haptics", meta=(AllowPrivateAccess="false"))
|
||||
uint8 bAutoStopAllHapticsOnEndPlay : 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="SenseGlove | Grab", meta=(AllowPrivateAccess="false"))
|
||||
FName GrabSocketName;
|
||||
|
||||
@@ -147,6 +150,16 @@ public:
|
||||
|
||||
void SetRight(const bool bInRight);
|
||||
|
||||
FORCEINLINE bool AutoStopsAllHapticsOnEndPlay() const
|
||||
{
|
||||
return !!bAutoStopAllHapticsOnEndPlay;
|
||||
}
|
||||
|
||||
FORCEINLINE void SetAutoStopAllHapticsOnEndPlay(const bool bInAutoStopAllHapticsOnEndPlay)
|
||||
{
|
||||
bAutoStopAllHapticsOnEndPlay = bInAutoStopAllHapticsOnEndPlay;
|
||||
}
|
||||
|
||||
FORCEINLINE const FName& GetGrabSocketName() const
|
||||
{
|
||||
return GrabSocketName;
|
||||
|
||||
@@ -78,6 +78,18 @@ void UVirtualHandComponentKismetLibrary::SetRight(USGVirtualHandComponent* Virtu
|
||||
VirtualHandComponent->SetRight(bInRight);
|
||||
}
|
||||
|
||||
bool UVirtualHandComponentKismetLibrary::AutoStopsAllHapticsOnEndPlay(
|
||||
const USGVirtualHandComponent* VirtualHandComponent)
|
||||
{
|
||||
return VirtualHandComponent->AutoStopsAllHapticsOnEndPlay();
|
||||
}
|
||||
|
||||
void UVirtualHandComponentKismetLibrary::SetAutoStopAllHapticsOnEndPlay(USGVirtualHandComponent* VirtualHandComponent,
|
||||
const bool bInAutoStopAllHapticsOnEndPlay)
|
||||
{
|
||||
VirtualHandComponent->SetAutoStopAllHapticsOnEndPlay(bInAutoStopAllHapticsOnEndPlay);
|
||||
}
|
||||
|
||||
const FName& UVirtualHandComponentKismetLibrary::GetGrabSocketName(const USGVirtualHandComponent* VirtualHandComponent)
|
||||
{
|
||||
return VirtualHandComponent->GetGrabSocketName();
|
||||
|
||||
@@ -81,6 +81,13 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static void SetRight(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, bool bInRight);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static bool AutoStopsAllHapticsOnEndPlay(const USGVirtualHandComponent* VirtualHandComponent);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static void SetAutoStopAllHapticsOnEndPlay(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent,
|
||||
const bool bInAutoStopAllHapticsOnEndPlay);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
static const FName& GetGrabSocketName(const USGVirtualHandComponent* VirtualHandComponent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user