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"

Changing character rotation to movement direction

I'm trying to setup a character so that it will rotate to the direction of the movement. e.g. push up it faces up, push left it faces left. I have set bUseControllerRotationYaw = false and GetCharacterMovement()->bOrientRotationToMovement = true;. From what I have been able to gather this is really all I need to do to get the movement to work as desired.

Here is the code I'm using for the character:

 // Fill out your copyright notice in the Description page of Project Settings.

 #include "RPG.h"
 #include "RPGCharacter.h"

 // Sets default values
     // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;

     bUseControllerRotationYaw = false;

     GetCharacterMovement()->bOrientRotationToMovement = true;
     GetCharacterMovement()->RotationRate = FRotator(0.0f, 0.0f, 540.0f);
     GetCharacterMovement()->MaxWalkSpeed = 400.0f;

 void ARPGCharacter::MoveVertical(float Value)
     if(Controller != NULL && Value != 0.0f)
         const FVector moveDir = FVector(1,0,0);
         AddMovementInput(moveDir, Value);

 void ARPGCharacter::MoveHorizontal(float Value)
     if(Controller != NULL && Value != 0.0f)
         const FVector moveDir = FVector(0,1,0);
         AddMovementInput(moveDir, Value);

 // Called when the game starts or when spawned
 void ARPGCharacter::BeginPlay()

 // Called every frame
 void ARPGCharacter::Tick( float DeltaTime )
  Super::Tick( DeltaTime );

 // Called to bind functionality to input
 void ARPGCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)


I have created a blueprint for the character and Inherited from ARPGCharacter. I have added the mannequin that is bundled with the animation starter kit as mesh and a customer camera class.

I'm not sure where else I should be looking to configure this correctly

Product Version: UE 4.11
more ▼

asked May 23 '16 at 07:17 AM in C++ Programming

avatar image

8 1 2 5

avatar image McBuff May 23 '16 at 09:51 AM

Are you sure that you need to disable bUseControllerRotationYaw? I mean from what I've gathered, you want to rotate around the Z axis, which is also referred to as yaw.

avatar image systmShok May 23 '16 at 04:06 PM

I am basing my implementation off a UE4 book I'm working through. From what I can tell the documentation recommends that it be cleared here

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

1 answer: sort voted first

Be sure the Rotation Rate property is not 0,0,0. This handles how fast it orients.

more ▼

answered May 23 '16 at 06:27 PM

avatar image

2.6k 98 16 97

avatar image systmShok May 23 '16 at 06:49 PM

I have the Rotation Rate set on line 16 with GetCharacterMovement()->RotationRate = FRotator(0.0f, 0.0f, 540.0f); . Is this what you mean?

avatar image RimmyD May 23 '16 at 07:39 PM


Does this work in your scene if you do it all through blueprint in the default properties of a character?

avatar image systmShok May 23 '16 at 07:59 PM

Inside of the CharacterMovement(Inherited) component under the player blueprint. I found that the Rotation Rate for the Yaw was 0 and the Pitch was 540.0. Maybe I'm reading the documentation wrong, but I thought the Third argument for FRotator was the yaw and the blueprint would have inherited that value. Anyway that fixed it, thank you very much for your help.

avatar image RimmyD May 23 '16 at 08:55 PM

ahh right, yeah from the docs:

FRotator ( float InPitch, float InYaw, float InRoll )

easy thing to miss for sure since the editor uses a different order.

(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