- /// "GrabLeft" is an FName for identifying the binding setting in the project settings
- /// currentInputMappings->GrabLeft is a TSubclassOf<UGameplayTask>
- BindButtonPressWithRelease("GrabLeft", currentInputMappings->GrabLeft, EControllerHand::Left);
- void APlayerCharacter_VR::BindButtonPressWithRelease(FName binding, TSubclassOf<UBehavior_Player> inClass, EControllerHand inHand)
- {
- if (IsValid(inClass))
- {
- InputComponent->BindAction<FPlayerTaskDelegate>(binding, IE_Pressed, this, &APlayerCharacter_VR::PlayerTaskClientServer, inClass, inHand);
- InputComponent->BindAction<FPlayerTaskDelegate>(binding, IE_Released, this, &APlayerCharacter_VR::PlayerInputRelease, inClass, inHand);
- BindReleaseInput(inClass, inHand);
- }
- }
- /// Release Mappings is just an array of structs containing a TSubclassOf<UGameplayTask> as the key
- /// an enum representing which hand
- /// and the relevant DECLARE_DELEGATE(FReleaseDelegate);
- void APlayerCharacter_VR::BindReleaseInput_Implementation(TSubclassOf<UBehavior_Player> inClass, EControllerHand inHand)
- {
- ReleaseMappings.Add(FReleaseInputMapping(inClass, inHand));
- }
- /// You can see here at line 31 the entry calls the FReleaseDelegate.ExecuteIfBound() from the input release struct
- void APlayerCharacter_VR::PlayerInputRelease_Implementation(TSubclassOf<UBehavior_Player> inClass, EControllerHand inHand)
- {
- if (ReleaseMappings.Contains(TPair<TSubclassOf<UBehavior_Player>, EControllerHand>(inClass, inHand)))
- {
- ReleaseMappings.FindByKey(TPair<TSubclassOf<UBehavior_Player>, EControllerHand>(inClass, inHand))->ReleaseMapping.ExecuteIfBound();
- }
- }
[text] Dynamic Binding Example
Viewer
Editor
You can edit this paste and save as new: