implement an optional feature in order to automatically stop all haptics on the end play event

This commit is contained in:
Mamadou Babaei
2023-05-19 18:15:44 +02:00
parent 1b390c525d
commit b51629e929
5 changed files with 40 additions and 5 deletions
+1
View File
@@ -15,6 +15,7 @@ This release breaks ABI/API compatibility with the previous versions.
- Added Linux AArch64 platform support.
- Added a new Grab component that can turn any actor into a grabbable object.
- Added a new Touch component that enables haptic feedbacks such as Buzz and Force-Feedback commands.
- Added an optional feature in order to automatically stop all haptics on the EndPlay event, wherever the virtual hand component is used. By default, it's enabled.
### Fixed
@@ -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);