Wednesday, February 28, 2024

Some more knowoledge on Enhanced input. Specifically bindings, and some gotchas

 So I was following a tutorial this morning. Another Stephen Ulibarri one. 

I got to othe point in his tutorial where I was to bind the functions to the input actions. And I have a pretty good idea of what i'm meant t do, so I went ahead to start, but there were quite a few trip ups I had, that in hindsight make sense. But I wanted to jot some notes down..




1. YOu have to declare your Input Action. I was under the impression All I needed to do was connect the IA like I would in blueprints, but just like mapping context you need to declare it. 

2. With the function that you're going to bind, you need to make sure it is a a ActionInput value. Or more specifically 

void Function ( const FInputActionValue& Value); 

I kept makinng the mistake of just passing in a float value. You need to make this an FInputActionValue reference if you're going to bind it to your enhanced action input). 

3. When you're binding your function to your Input Action. The syntax for BindAction() goes. 

BindAction(InputAction, ETriggerEvent::(WhateverTheEventIs), this(the actor it's acting on), A_The specific  actor::TheFunctinYou'reBinding). 

I really had trouble with it this morning, but I hope htis clear is up for you future Paul. 


ALSO here's the setup for the ball, in the ball maze projec tyou did. 




// Called to bind functionality to input

void AC_PlayerBall::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)

{

Super::SetupPlayerInputComponent(PlayerInputComponent);


if (UEnhancedInputComponent* BallInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {


BallInputComponent->BindAction(BallMove, ETriggerEvent::Triggered, this, &AC_PlayerBall::BallMovementFunction);

}



}