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. 

Issues getting player input properly setup

I am trying to translate this Blueprint tutorial into C++ code.


I started with the main 3rd person C++ project. I have two issues at this point.

GetActorForwardVector() for moving backwards always points in the direction that I spawned. So doesn't matter which direction you turn to, if you start walking backwards you always go in the original backwards location.

I cannot use the same Forward Vector that I'm using to move forward (or can I?), I want the character to appear to walk backwards. When I use the same one, he flips around.

 void ATestCharacter::MoveForward(float Value)
     if ((Controller != NULL) && (Value != 0.0f))
         // find out which way is forward
         const FRotator Rotation = Controller->GetControlRotation();
         const FRotator YawRotation(0, Rotation.Yaw, 0);
         // get forward vector
         FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);        
         if (Value < 0)
             Direction = GetActorForwardVector();
             Value *= 0.5f; 
         AddMovementInput(Direction, Value); 

The other problem is my mouse look adds all kinds of weird pitch. The default one kinda locks you into the x,y planes, but with this I am getting all kinds of Z.

 void ATestCharacter::TurnAtRate(float Rate)
     // calculate delta for this frame from the rate information
     //AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
     if (!bRightMouseDown)
     CameraBoom->AddRelativeRotation(FRotator(0.0f, Rate, 0.0f));
 //    CameraBoom->AddLocalRotation(FRotator(0.0f, Rate, 0.0f));
 void ATestCharacter::LookUpAtRate(float Rate)
     if (!bRightMouseDown)
     CameraBoom->AddRelativeRotation(FRotator(Rate, 0.0f, 0.0f));
     //CameraBoom->AddLocalRotation(FRotator(Rate, 0.0f, 0.0f));
     // calculate delta for this frame from the rate information
     //AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());

Here's full source code:

Header: http://pastebin.com/5EAKhJrc

Source: http://pastebin.com/YMqFKMBx

Inputs: http://i.imgur.com/GjZXPUG.png

Can anyone quickly see where I'm screwing up? It's kind of hard to translate Blueprints correctly when the functions aren't really 1:1.

Product Version: UE 4.10
more ▼

asked Mar 22 '16 at 01:04 PM in C++ Programming

avatar image

36 2 4 10

(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