void UGrabber::BeginPlay()
{
Super::BeginPlay();
// Present by default, doesn't need check
Input = GetOwner()->FindComponentByClass<UInputComponent>();
Input->BindAction(TEXT("Grab"), EInputEvent::IE_Pressed, this, &UGrabber::Grab);
Input->BindAction(TEXT("Grab"), EInputEvent::IE_Released, this, &UGrabber::Grab);
// ...
}
void UGrabber::Grab()
{
static bool Pressed = false;
Pressed = !Pressed;
UE_LOG(LogTemp, Warning, TEXT("Grabby grabton %s."), Pressed ? TEXT("Pressed") : TEXT("Released"))
}
Looking good! How are you enjoying the course?
I did the original course a few years ago, so it’s always a pleasure to refresh my knowledge.