added abilitInputID action handling
This commit is contained in:
Binary file not shown.
BIN
Content/Input/GAS/IA_BasicAttack.uasset
LFS
Normal file
BIN
Content/Input/GAS/IA_BasicAttack.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Input/IM_Gameplay.uasset
LFS
BIN
Content/Input/IM_Gameplay.uasset
LFS
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Crunch/Public/Character/CPlayerCharacter.h"
|
#include "Crunch/Public/Character/CPlayerCharacter.h"
|
||||||
|
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
#include "Crunch/Public/Player/CPlayerController.h"
|
#include "Crunch/Public/Player/CPlayerController.h"
|
||||||
#include "GameFramework/SpringArmComponent.h"
|
#include "GameFramework/SpringArmComponent.h"
|
||||||
@@ -52,6 +53,17 @@ void ACPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCo
|
|||||||
EnhancedInputComp->BindAction(JumpInputAction, ETriggerEvent::Triggered, this, &ThisClass::Jump);
|
EnhancedInputComp->BindAction(JumpInputAction, ETriggerEvent::Triggered, this, &ThisClass::Jump);
|
||||||
EnhancedInputComp->BindAction(LookInputAction, ETriggerEvent::Triggered, this, &ThisClass::HandleLookInput);
|
EnhancedInputComp->BindAction(LookInputAction, ETriggerEvent::Triggered, this, &ThisClass::HandleLookInput);
|
||||||
EnhancedInputComp->BindAction(MoveInputAction, ETriggerEvent::Triggered, this, &ThisClass::HandleMoveInput);
|
EnhancedInputComp->BindAction(MoveInputAction, ETriggerEvent::Triggered, this, &ThisClass::HandleMoveInput);
|
||||||
|
|
||||||
|
for (const auto InputIdPair : GameplayAbilityInputActions)
|
||||||
|
{
|
||||||
|
EnhancedInputComp->BindAction(
|
||||||
|
InputIdPair.Value,
|
||||||
|
ETriggerEvent::Triggered,
|
||||||
|
this,
|
||||||
|
&ThisClass::HandleAbilityInput,
|
||||||
|
InputIdPair.Key
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +83,15 @@ void ACPlayerCharacter::HandleMoveInput(const FInputActionValue& InputActionValu
|
|||||||
AddMovementInput(GetMoveFwdDir() * InputVal.Y + GetLookRightDir() * InputVal.X);
|
AddMovementInput(GetMoveFwdDir() * InputVal.Y + GetLookRightDir() * InputVal.X);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACPlayerCharacter::HandleAbilityInput(const FInputActionValue& InputActionValue, ECAbilityInputID InputID)
|
||||||
|
{
|
||||||
|
const bool bPressed{InputActionValue.Get<bool>()};
|
||||||
|
const auto AbilitySystemComponent{GetAbilitySystemComponent()};
|
||||||
|
bPressed
|
||||||
|
? AbilitySystemComponent->AbilityLocalInputPressed(static_cast<int32>(InputID))
|
||||||
|
: AbilitySystemComponent->AbilityLocalInputReleased(static_cast<int32>(InputID));
|
||||||
|
}
|
||||||
|
|
||||||
FVector ACPlayerCharacter::GetLookRightDir() const
|
FVector ACPlayerCharacter::GetLookRightDir() const
|
||||||
{
|
{
|
||||||
return ViewCamera->GetRightVector();
|
return ViewCamera->GetRightVector();
|
||||||
|
|||||||
@@ -24,13 +24,22 @@ void UCAbilitySystemComponent::GiveInitialAbilities()
|
|||||||
{
|
{
|
||||||
if (!GetOwner() || !GetOwner()->HasAuthority()) return;
|
if (!GetOwner() || !GetOwner()->HasAuthority()) return;
|
||||||
|
|
||||||
for (const auto& AbilityClass : Abilities)
|
for (const auto& AbilityPairClass : Abilities)
|
||||||
{
|
{
|
||||||
GiveAbility(FGameplayAbilitySpec(AbilityClass, 0, -1, nullptr));
|
GiveAbility(FGameplayAbilitySpec(
|
||||||
|
AbilityPairClass.Value,
|
||||||
|
0,
|
||||||
|
static_cast<int32>(AbilityPairClass.Key),
|
||||||
|
nullptr
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
for (const auto& AbilityPairClass : BasicAbilities)
|
||||||
for (const auto& AbilityClass : BasicAbilities)
|
|
||||||
{
|
{
|
||||||
GiveAbility(FGameplayAbilitySpec(AbilityClass, 1, -1, nullptr));
|
GiveAbility(FGameplayAbilitySpec(
|
||||||
|
AbilityPairClass.Value,
|
||||||
|
1,
|
||||||
|
static_cast<int32>(AbilityPairClass.Key),
|
||||||
|
nullptr
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
Source/Crunch/Private/GAS/CGameplayAbilityTypes.cpp
Normal file
4
Source/Crunch/Private/GAS/CGameplayAbilityTypes.cpp
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// Multiplayer By Caleb
|
||||||
|
|
||||||
|
|
||||||
|
#include "GAS/CGameplayAbilityTypes.h"
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "UCAbilitySystemStatics.h"
|
|
||||||
|
#include "GAS/UCAbilitySystemStatics.h"
|
||||||
|
|
||||||
#include "GameplayTagContainer.h"
|
#include "GameplayTagContainer.h"
|
||||||
|
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "CCharacter.h"
|
#include "CCharacter.h"
|
||||||
#include "CPlayerCharacter.generated.h"
|
#include "CPlayerCharacter.generated.h"
|
||||||
|
|
||||||
|
enum class ECAbilityInputID : uint8;
|
||||||
class UInputAction;
|
class UInputAction;
|
||||||
class UInputMappingContext;
|
class UInputMappingContext;
|
||||||
class UCameraComponent;
|
class UCameraComponent;
|
||||||
@@ -33,6 +34,13 @@ private:
|
|||||||
UPROPERTY(EditDefaultsOnly, Category= "View")
|
UPROPERTY(EditDefaultsOnly, Category= "View")
|
||||||
FRotator RotationRate{FRotator(0.0f, 720.0f, 0.0f)};
|
FRotator RotationRate{FRotator(0.0f, 720.0f, 0.0f)};
|
||||||
|
|
||||||
|
FVector GetLookRightDir() const;
|
||||||
|
FVector GetLookFwdDir() const;
|
||||||
|
FVector GetMoveFwdDir() const;
|
||||||
|
|
||||||
|
/*************************************************************************************/
|
||||||
|
//------------------------------ Input------------------------------------------------
|
||||||
|
/*************************************************************************************/
|
||||||
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
||||||
TObjectPtr<UInputMappingContext> GameplayMappingContext;
|
TObjectPtr<UInputMappingContext> GameplayMappingContext;
|
||||||
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
||||||
@@ -41,11 +49,11 @@ private:
|
|||||||
TObjectPtr<UInputAction> LookInputAction;
|
TObjectPtr<UInputAction> LookInputAction;
|
||||||
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
||||||
TObjectPtr<UInputAction> MoveInputAction;
|
TObjectPtr<UInputAction> MoveInputAction;
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category= "Input")
|
||||||
|
TMap<ECAbilityInputID, UInputAction*> GameplayAbilityInputActions;
|
||||||
|
|
||||||
void HandleLookInput(const FInputActionValue& InputActionValue);
|
void HandleLookInput(const FInputActionValue& InputActionValue);
|
||||||
void HandleMoveInput(const FInputActionValue& InputActionValue);
|
void HandleMoveInput(const FInputActionValue& InputActionValue);
|
||||||
|
void HandleAbilityInput(const FInputActionValue& InputActionValue, ECAbilityInputID AbilityInputID);
|
||||||
|
|
||||||
FVector GetLookRightDir() const;
|
|
||||||
FVector GetLookFwdDir() const;
|
|
||||||
FVector GetMoveFwdDir() const;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "CAbilitySystemComponent.generated.h"
|
#include "CAbilitySystemComponent.generated.h"
|
||||||
|
|
||||||
|
enum class ECAbilityInputID : uint8;
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class CRUNCH_API UCAbilitySystemComponent : public UAbilitySystemComponent
|
class CRUNCH_API UCAbilitySystemComponent : public UAbilitySystemComponent
|
||||||
{
|
{
|
||||||
@@ -21,8 +23,8 @@ private:
|
|||||||
TArray<TSubclassOf<UGameplayEffect>> InitialEffects;
|
TArray<TSubclassOf<UGameplayEffect>> InitialEffects;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
||||||
TArray<TSubclassOf<UGameplayAbility>> Abilities;
|
TMap<ECAbilityInputID, TSubclassOf<UGameplayAbility>> Abilities;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
UPROPERTY(EditDefaultsOnly, Category="Gameplay Ability")
|
||||||
TArray<TSubclassOf<UGameplayAbility>> BasicAbilities;
|
TMap<ECAbilityInputID, TSubclassOf<UGameplayAbility>> BasicAbilities;
|
||||||
};
|
};
|
||||||
|
|||||||
24
Source/Crunch/Public/GAS/CGameplayAbilityTypes.h
Normal file
24
Source/Crunch/Public/GAS/CGameplayAbilityTypes.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Multiplayer By Caleb
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "CGameplayAbilityTypes.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UENUM(BlueprintType)
|
||||||
|
enum class ECAbilityInputID : uint8
|
||||||
|
{
|
||||||
|
None UMETA(DisplayName = "None"),
|
||||||
|
BasicAttack UMETA(DisplayName = "BasicAttack"),
|
||||||
|
AbilityOne UMETA(DisplayName = "AbilityOne"),
|
||||||
|
AbilityTwo UMETA(DisplayName = "AbilityTwo"),
|
||||||
|
AbilityThree UMETA(DisplayName = "AbilityThree"),
|
||||||
|
AbilityFour UMETA(DisplayName = "AbilityFour"),
|
||||||
|
AbilityFive UMETA(DisplayName = "AbilityFive"),
|
||||||
|
AbilitySix UMETA(DisplayName = "AbilitySix"),
|
||||||
|
Confirm UMETA(DisplayName = "Confirm"),
|
||||||
|
Cancel UMETA(DisplayName = "Cancel"),
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user