Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

BindAction and EnableInput not working for an Actor

I'm using EnableInput whenever the beginoverlap event is called and the OtherActor is my character but it doesn't work. I googled around and couldn't find any answers that worked for me is there something I'm missing? Using when I use the Fire Event in blueprints it works even without enabling input.

Setup in the Header file:

 void FireHandler();
 UInputComponent* InputComp;

Inside the constructor:

 InputComp = CreateDefaultSubobject<UInputComponent>(TEXT("InputComp"));
 InputComp->bBlockInput = bBlockInput;


 InputComp->BindAction("Fire", IE_Pressed, this, &AMasterWeapon::FireHandler);


 ACharacter* MyChar = Cast<ACharacter>(OtherActor);
 if (MyChar != nullptr) {
     UE_LOG(LogTemp, Warning, TEXT("In"));


 UE_LOG(LogTemp, Warning, TEXT("Fire"));
Product Version: UE 4.21
more ▼

asked Mar 20 '19 at 12:08 PM in C++ Programming

avatar image

1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Managed to fix it. Seems like every actor has a variable called InputComponent by default and by using

 InputComponent = InputComp;

In BeginPlay my problem was solved.

more ▼

answered Mar 22 '19 at 02:28 PM

avatar image

1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question