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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How do I set up input inside the PlayerController instead of the character?

I want to handle input inside a custom player controller class instead of my character's class. Do I have to cast? If yes the how? I tried searching everywhere but for some reason nothing helped.

Product Version: UE 4.17
more ▼

asked Nov 07 '17 at 07:07 PM in C++ Programming

avatar image

Pencil Amazing
13 3 3 7

avatar image ImVawx ♦♦ STAFF Nov 07 '17 at 10:41 PM

You should be able to use the SetupInputComponent() function inside of the PlayerController class -- or YourPlayerController class, inherited from PlayerController.

If you look at the function, it creates a InputComponent that you can then use to bind input to.

There may be more to this step, such as making sure that the controller is the one accepting input, instead of the the Character. I am not 100% but I would start by looking at the player controller function and see if you can use it in a way you want.

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

1 answer: sort voted first

Inside your CustomCharacterController.h file, you need something like this:

 virtual void SetupInputComponent() override;

Then, in your cpp file:

 void ACustomCharacterController::SetupInputComponent()
     InputComponent->BindAction("MyAction", IE_Pressed, this, &ACustomCharacterController::FunctionToCall);

Then, just make sure the game's spawning your custom character controller for the player and not the default controller. That's usually set in the GameMode you're running.

more ▼

answered Nov 07 '17 at 11:26 PM

avatar image

21 1 2

avatar image MasBASS Apr 13 '19 at 02:46 AM

Raap ! You saved my time and my life ! Thank you :D

(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