x

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"

UE4 BindAxis doesnt work

Hi! I'm trying to setup my pawn movement but something tries to stop this process. I've tried to log the value and the result was value=0. I double checked the input settings but everything was ok. Here is my code:

 void ASCharatcer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
     {
     Super::SetupPlayerInputComponent(PlayerInputComponent);
 
     PlayerInputComponent->BindAxis("MoveForward", this, &ASCharatcer::MoveForward);
     PlayerInputComponent->BindAxis("MoveRight", this, &ASCharatcer::MoveRight);
 }
 
 void ASCharatcer::MoveForward(float Value)
 {
     AddMovementInput(GetActorForwardVector() * Value);
     UE_LOG(LogTemp, Warning, TEXT("Value %d"), Value)
 }
 
 
 void ASCharatcer::MoveRight(float Value)
 {
     AddMovementInput(GetActorRightVector() * Value);
 }
Product Version: UE 4.19
Tags:
more ▼

asked May 21 '18 at 06:23 PM in C++ Programming

avatar image

Karixs
1

avatar image 92Rob May 22 '18 at 03:04 PM

What device are you using to test ? Keyboards will only output -1, 0 and 1 while a thumbstick for example would give you a value between -1 and 1. it will call it with value 0 when the key isnt pressed.

I don't see anything wrong with your code, are you sure youre pressing the right key? :)

avatar image Jawdy May 26 '18 at 10:15 AM

Further to what 92Rob has suggested, make sure you've correctly spelled your Input Axis Names in the Editor, so that MoveForward and MoveRight are 100% what is in the Editor (you've spelled Character incorrectly in your class name).

Also, check that you've set your Character class as the default pawn in the Game Mode, so that it's the one used/spawned. (I would suspect you have already done this, as you say it's outputting the log!)

avatar image Caviarail Jun 11 '18 at 02:10 PM

Maybe (happened to me) I wanted to add/change behaviour in C++ and something else was already done in a Blueprint. Took me a while to notice that the event node is consuming the input and the binding functions are not executed in this case.

So you might check your blueprint input actions, if you have some.

alt text

consumpeinput.png (29.5 kB)
(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Log value result is 0, because UE_LOG(LogTemp, Warning, TEXT("Value %d"), Value). Try using UE_LOG(LogTemp, Warning, TEXT("Value %f"), Value) instead.

more ▼

answered Sep 21 '18 at 03:01 AM

avatar image

Kiry
31 2 7

(comments are locked)
10|2000 characters needed characters left
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