Skip to content

Commit

Permalink
UHL InputConfig, add instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciberusps committed Sep 11, 2024
1 parent 2959959 commit c9190f9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,38 @@ Features:

##### InputConfig (GAS abilities input binding)

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

![image](https://github.com/user-attachments/assets/2c72400e-1122-40b2-aa73-4bfc1e212d0f)

Setup:

- turn on `bUseInputConfig` on `UHLAbilitySystemComponent`
- 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`

```c++
void AUHLPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);

UUHLInputComponent* UHLInputComponent = CastChecked<UUHLInputComponent>(PlayerInputComponent);
UUHLInputConfig* UHLInputConfig = AbilitySystemComponent->InputConfig;
TArray<uint32> BindHandles;
UHLInputComponent->BindAbilityActions(UHLInputConfig, AbilitySystemComponent, &UUHLAbilitySystemComponent::AbilityInputTagPressed, &UUHLAbilitySystemComponent::AbilityInputTagReleased, BindHandles);

if (UHLInputComponent)
{
UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_Move.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputMove);
UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_Move.InputAction, ETriggerEvent::Completed, this, &AUHLPlayerCharacter::InputStopMove);

UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_LookMouse.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputLook);
UHLInputComponent->BindAction(UHLInputConfig->NativeInputAction_LookStick.InputAction, ETriggerEvent::Triggered, this, &AUHLPlayerCharacter::InputLook);
}
}
```
##### AbilityInputCache
Expand Down Expand Up @@ -355,14 +386,6 @@ Get names of actor components on object, usefull for [`GetOptions` UPROPERTY](ht
#### `GetHighestPoint`
#### `InputSystem`

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

- abilities should nest from `UHLGameplayAbility` for "ActivationPolicy" work correctly
- SetupPlayerInputComponent - bind all from input config, `BindAbilityActions`
- `Project Settings -> Input -> Default Input Component Class` -> change on `UHLInputComponent`

### LoadingUtilLibrary
**UHLLoadingUtilLibrary** - loading utils from Lyra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void UUHLAbilitySystemComponent::AbilitySpecInputReleased(FGameplayAbilitySpec&
}
}

void UUHLAbilitySystemComponent::AbilityInputTagPressed(const FGameplayTag& InputTag)
void UUHLAbilitySystemComponent::AbilityInputTagPressed(const FGameplayTag InputTag)
{
if (InputTag.IsValid())
{
Expand All @@ -200,7 +200,7 @@ void UUHLAbilitySystemComponent::AbilityInputTagPressed(const FGameplayTag& Inpu
}
}

void UUHLAbilitySystemComponent::AbilityInputTagReleased(const FGameplayTag& InputTag)
void UUHLAbilitySystemComponent::AbilityInputTagReleased(const FGameplayTag InputTag)
{
if (InputTag.IsValid())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Input/AbilityInputCache.h"
#include "UHLAbilitySystemComponent.generated.h"

class UUHLInputConfig;
class UUHLGameplayAbility;
/**
*
Expand Down Expand Up @@ -39,6 +40,8 @@ class UNREALHELPERLIBRARY_API UUHLAbilitySystemComponent : public UAbilitySystem
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bUseInputConfig = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(EditCondition="bUseInputConfig"))
UUHLInputConfig* InputConfig;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(EditCondition="bUseInputConfig"))
bool bUseAbilityInputCache = false;
// if enabled - caching works only in predefined user windows - ANS_AbilityInputCache_CacheWindow
// if disabled - works always
Expand All @@ -55,12 +58,11 @@ class UNREALHELPERLIBRARY_API UUHLAbilitySystemComponent : public UAbilitySystem
virtual void OnUnregister() override;

/** Input Config **/
// TODO DA_InputConfig, UHLGameplayAbility
void ProcessAbilityInput(float DeltaTime, bool bGamePaused);
virtual void AbilitySpecInputPressed(FGameplayAbilitySpec& Spec) override;
virtual void AbilitySpecInputReleased(FGameplayAbilitySpec& Spec) override;
virtual void AbilityInputTagPressed(const FGameplayTag& InputTag);
virtual void AbilityInputTagReleased(const FGameplayTag& InputTag);
virtual void AbilityInputTagPressed(const FGameplayTag InputTag);
virtual void AbilityInputTagReleased(const FGameplayTag InputTag);
/** Input Config **/

UFUNCTION(BlueprintCallable)
Expand Down

0 comments on commit c9190f9

Please sign in to comment.