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"

Handling input in AActor without blocking/consuming it

I'd like to have several Actors in my game responding to player input simultaneously while having player's pawn respond to input too.

I've created an AActor class to test this functionality. It should respond to input and send it down the stack without consuming it. But for some reason input handled by this actor doesn't get passed to pawn. If there's a few of these actors in my level, each of them is responding to input just fine, but my pawn stops responding to this specific input whatsoever.

Steps to recreate this problem: 1. Create new project from First Person template 2. Create new C++ class and add code from snippet below to it 3. Spawn few actors from this class during runtime - you'll see that you can't move sideways anymore

C++ code for this actor: MyActor.h:

 class TESTPROJECTCPP_API AMyActor : public AActor
     virtual void BeginPlay() override;
     void MyFun(float AxisValue);


 void AMyActor::BeginPlay()
     bBlockInput = false;
     const APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
     InputComponent->bBlockInput = false;    //just in case
     FInputAxisBinding Binding = InputComponent->BindAxis(TEXT("MoveRight"), this, &AMyActor::MyFun);
     Binding.bConsumeInput = false;
 void AMyActor::MyFun(float AxisValue)
     if (GEngine)
         GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Red, TEXT("Hello world"));

Blueprint spawning those actors during runtime: Blueprint spawning c++ actors during runtime

Input stack:

Input stack

My question is: - Am I doing something wrong? - What can I do to make input go to my actors AND my pawn?

Product Version: UE 4.16
inputstack.png (201.0 kB)
more ▼

asked Aug 30 '17 at 10:17 AM in C++ Programming

avatar image

Daniel janowski
1 1 1 3

avatar image dldls Oct 21 '17 at 10:44 PM

FInputAxisBinding Binding is the problem. You're storing binding by value, making a copy of it, then setting Binding.bConsumeInput in that copy not in a binding inside input component. You need to store Binding by reference (&) FInputAxisBinding& Binding; Binding.BConsumeInput = false; then this actor will not consume input.

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

0 answers: sort voted first
Be the first one to answer this question
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