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"

How do I read input axes from C++?

How can I read input axes from C++ code without setting up events? In Blueprint I can just read the axis values with the Get Axisname node, however I'm not able to get these values with the C++ API.

Any of the following lines I tried always return 0 in both a APawn and a APlayerController inheritance.


Accelerate is set up as an AxisMapping in the project settings with W and S with scales of 1.0 respective -1.0. Auto Receive Input is set to Player 0 in the Blueprint instance of the actor.

What do I have to do to be able to read input axes, preferably from a PlayerController?

Product Version: Not Selected
more ▼

asked Nov 24 '14 at 06:16 PM in C++ Programming

avatar image

21 3 5 10

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

2 answers: sort voted first

It is actually possible, you have to bind, but you can get the input in Tick, if you use InputComponent->GetAxisValue(TEXT("Accelerate"));, you need to put InputComponent->BindAxis(TEXT("Accelerate")); in your SetupInputComponent, so it registers that axis value so you can read it.

more ▼

answered Nov 25 '14 at 04:52 PM

avatar image

36 2 5 11

avatar image huulong Sep 12 '16 at 08:09 PM

Yes, this is explained in the API for the 1st overload of BindAxis here. If you followed programming tutorials, you probably know the 2nd overload, with delegate functions.

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

Hey guys,

Unfortunately you can just get key from InputComponent without key binding. If I correctly understand you, you want to do something like this:

 // PlayerInput exist in PlayerController
 if (PlayerInput)
     float BValue = PlayerInput->GetKeyValue(EKeys::B);
     // to do smth

Best regards, Gleb

more ▼

answered Nov 25 '14 at 04:44 PM

avatar image

1.8k 76 19 143

(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