Declare grab callback

This commit is contained in:
2024-09-09 00:25:45 -04:00
parent 9a555e2227
commit 92090a3ae5
2 changed files with 16 additions and 1 deletions
@@ -47,7 +47,7 @@ void ALumiCharacter::BeginPlay()
{
Super::BeginPlay();
//Add Input Mapping Context
// Add Input Mapping Context
if (const APlayerController* PlayerController = Cast<APlayerController>(Controller))
{
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<
@@ -72,6 +72,11 @@ void ALumiCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
// Set up action bindings
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent))
{
// Grabbing
EnhancedInputComponent->BindAction(GrabAction,
ETriggerEvent::Triggered,
this,
&ALumiCharacter::OnGrabTriggered);
// Jumping
EnhancedInputComponent->BindAction(JumpAction,
ETriggerEvent::Started,
@@ -107,6 +112,11 @@ void ALumiCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
}
}
void ALumiCharacter::OnGrabTriggered(const FInputActionValue& Value)
{
UE_LOG(LogLumiCharacter, Log, TEXT("Grab Triggered"));
}
void ALumiCharacter::OnJumpStarted(const FInputActionValue& Value)
{
Jump();
@@ -32,6 +32,9 @@ class WIZARDINGCENTRAL_API ALumiCharacter : public ACharacter
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputMappingContext* DefaultMappingContext;
/** Grab Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputAction* GrabAction;
/** Jump Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputAction* JumpAction;
@@ -58,6 +61,8 @@ public:
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
private:
// Grab
void OnGrabTriggered(const FInputActionValue& Value);
// Jump
void OnJumpStarted(const FInputActionValue& Value);
void OnJumpHold(const FInputActionValue& Value);