Skip to content

Commit

Permalink
update UHL InputConfig setup instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciberusps committed Sep 12, 2024
1 parent c9190f9 commit 006ee79
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Features:
- apply `InitialGameplayTags`
- Lyra-like "InputConfig", GAS abilities input binding

##### InputConfig (GAS abilities input binding)
##### InputConfig (GAS abilities input binding) [optional]

Binding InputActions to GameplayAbilities using tags, like in Lyra but enhanced and adopted for 3d action game.

Expand All @@ -155,9 +155,10 @@ Setup:
- create `InputConfig` - `DataAsset` nested from `UHLInputConfig`
- abilities should nest from `UHLGameplayAbility` for `ActivationPolicy` work correctly
- in `Project Settings -> Input -> Default Input Component Class` -> set `UHLInputComponent`
- in your PlayerCharacter class add lines in `SetupPlayerInputComponent` for bind actions from `InputConfig`
- in your PlayerCharacter class add lines in `SetupPlayerInputComponent` for binding actions from `InputConfig`

```c++
// Your PlayerCharacter class
void AUHLPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
Expand All @@ -167,6 +168,7 @@ void AUHLPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInput
TArray<uint32> BindHandles;
UHLInputComponent->BindAbilityActions(UHLInputConfig, AbilitySystemComponent, &UUHLAbilitySystemComponent::AbilityInputTagPressed, &UUHLAbilitySystemComponent::AbilityInputTagReleased, BindHandles);

// optional
if (UHLInputComponent)
{
UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_Move.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputMove);
Expand All @@ -178,6 +180,49 @@ void AUHLPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInput
}
```
- in your PlayerController class add
```c++
// Your PlayerController.cpp
void AUHLPlayerController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
CachedPlayerCharacter = Cast<AUHLPlayerCharacter>(InPawn);
}
void AUHLPlayerController::PostProcessInput(const float DeltaTime, const bool bGamePaused)
{
Super::PostProcessInput(DeltaTime, bGamePaused);
if (CachedPlayerCharacter.Get() == nullptr) return;
if (UUHLAbilitySystemComponent* ASC = CachedPlayerCharacter.Get()->GetUHLAbilitySystemComponent())
{
ASC->ProcessAbilityInput(DeltaTime, bGamePaused);
}
}
// Your PlayerController.h
UCLASS()
class UHL_API AUHLPlayerController : public APlayerController
{
GENERATED_BODY()
protected:
virtual void OnPossess(APawn* InPawn) override;
virtual void PostProcessInput(const float DeltaTime, const bool bGamePaused) override;
private:
TWeakObjectPtr<AUHLPlayerCharacter> CachedPlayerCharacter;
};
```

How to use:
- every `UHLGameplayAbility`

##### AbilityInputCache

`AbilityInputCache`
Expand Down

0 comments on commit 006ee79

Please sign in to comment.