(Unreal Engine) Pinch doesn't work properly in multiplayer.
It's version 5.5.4 and sdk version is being developed as 78.0.
I'm developing a case where 3 people multi-play, and different Pawn can be set up each player.
For example, one person is DefaultPawn, the other is IsdkSamplePawn, IsdkSamplePawn2, and so on.
The two Pawn's are using hand-tracking.
The code link that I referenced to make different Pawn is like
https://unreal.gg-labs.com/wiki-archives/networking/spawn-different-pawns-for-players-in-multiplayer
and this is Unreal 4, so I modify the code to version 5.
By the way, if the Player Controller class calls GameMode's RestartPlayer within DeterminePawnClass,
Pinch grab action does not work in handtracking.
I think it's a bug of RigComponent in InteractionSDK,
but I wonder if anyone has solved this problem.
I’ve been struggling for days with Pinch Grab not working in multiplayer using the Meta Interaction SDK (UE5).
Palm Grab worked fine, but Pinch never fired on clients — even though single-player worked perfectly.After digging through the SDK source code, I finally found the root cause and a clean workaround.
I’m sharing it here in case anyone else is fighting the same issue.
I found it's not related to GameMode's RestartPlayer function, it's just Meta InteractionSDK bug need to patch when multiplay
First, I added InteractionSDK project codes into my plugins folder, so I can make break point and debug..
In UIsdkHandRigComponent::BeginPlay(), the Interaction SDK tries to bind input actions: (it call parent UIsdkRigComponent::BeginPlay() function call, super::BeginPlay()),
Inside UIsdkRigComponent::BeginPlay(), there is below codes,
if (bAutoBindInputActions)
{
AActor* OwnerActor = GetOwner();
OwnerActor->EnableInput(LocalPlayer);
auto EnhancedInputComponent = OwnerActor->FindComponentByClass<UEnhancedInputComponent>();if (EnhancedInputComponent)
{
BindInputActions(EnhancedInputComponent);
}......
}
Single Play or Multiplay as ListenServer Play, it's okay, because the Pawn’s InputComponent has already been created before BeginPlay.
But, Multiplay as Client, FindComponentByClass<UEnhancedInputComponent>() returns nullptr, So Pinch input actions never get bound on the clientMaybe there are two to fix the problem, one is delay bind or check bind until find UEnhancedInputComponent
I tested two ways, all make work in multiplay client pinch action
As second way, I made a function like below
void UIsdkHandRigComponent::BindPinchInputActions()
{
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if (!OwnerPawn || !OwnerPawn->IsLocallyControlled())
return;const auto FirstLocalPlayer = UGameplayStatics::GetPlayerController(this, 0);
AActor* OwnerActor = GetOwner();
OwnerActor->EnableInput(FirstLocalPlayer);
const auto EnhancedInputComponent = OwnerActor->FindComponentByClass<UEnhancedInputComponent>();
if (EnhancedInputComponent)
{
BindInputActions(EnhancedInputComponent);
}
}and I checked in TickCompoent function
void UIsdkHandRigComponent::TickComponent(
float DeltaTime,
ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);if (IsPinchGrabBinded == false)
{
BindPinchInputActions();
}(I added IsPinchGrabBinded = true; into BindPinchInputActions() function if bind successed)
Pinch Grab failed in MP because Interaction SDK attempts to bind input in BeginPlay before the client creates its EnhancedInputComponent.
Delaying or retrying the binding fixes it fully.Hopefully, this saves someone hours of debugging the Interaction SDK internals