Download

How do you put a UMG button as a action Mapping?

I already know that there are forums out there about this topic but all of I dont understand, I need to make a button which shoots. I have already tried the “ListenForInputAction” node but no luck pls help.2021-05-16 (2)

You need to create a method “Fire” and add the binding in code (C++ example).

// Called to bind functionality to input
void ACameraDefaultPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    PlayerInputComponent->BindAction("Fire", IE_Pressed, this, &ACameraDefaultPawn::Fire);
}

thanks for the reply, by method do you mean custom event?

sorry i am a bit new to coding

This is the method binding to. You simply do something like that in the header:

void Fire();

And in the cpp file:

void ACameraDefaultPawn::Fire() {
   // do anything here you want on pressing buttons or similar
}

It’s in the same class where you setup player input component.

thanks so much, is it possible to use C++ in in UMG?

I dont kow C++ and how to use it Unreal Engine. I also do not know what the cpp file is. I know it has been a long time since my last post but i really have to make this button. If you could help me that would be awesome.