Character Movement Issues - Orient rotation to movement has no affect!

Hello okay to start I am new to all of this. But I have worked with ue4 before, newer specifically to c++.
So, first I made a custom character. Made customer animation blueprint. I will post what I have in there as screenshots.
Next I followed this tutorial to a Tee.

I am sure many of you are farmiliar.
So I will also include my c++ code as well. Just know it is exactly as his is.
Here is exactly how my character moves.
w - forward as expected
s - backward as expected.
d/a - He uses his walking forward animation but moves left/right. In the video and what I would want is that no matter which direction he moves, he faces the direction he is moving. From my understanding this function should take care of that: GetCharacterMovement()->bOrientRotationToMovement = true;
I don’t have desired rotation.
Because this is not working I tried setting it to false and even commenting it out, NO CHANGE TO MY GAME. I don’t understand why this is not effecting my character movement. But wait!! There’s more…

I have commented out SEVERAL lines of code in the .cpp file, (using //) and literally with all of them commented out other than move forward and move right, as well as some camera attachment settings and jump, no change is made to his movement. This tells me that perhaps although it is possible that these lines should be what I need for the controls to act how I want, they are playing no role what so ever in my characters movement.
I will post my initial c++ doc and then I will also provide my commented out one where the character has no difference in movement. I will put !!! beside the comments so you know which lines have NO IMPACT.

Can someone please help me understand what to do here. I want my character to move exactly like his in this video. Honestly, I am trying to mimic the character movement of the mechanics in Spongebob battle for bikini bottom. I love that game!
Thank you in advance!

1 Like

Are you using a character BP, which is a child from this c++ class? If so, make sure “Orient Rotation to Movement” is really checked.

1 Like
  • You created a C++ class, named XXX.
  • Then you created a BP character based on the XXX class. This can be observed in the right upper conner of the BP:

303771-1.jpg

  • Now, in the BP, select the character movement component;
  • Go to the details panel, and search for “Orient Rotation to Movement”;
  • Is is check or uncheck? If not checked, then check it.

I believe so, I was following the tutorial and I think I know what you mean and I would have selected it as that. But just in case that is not the case how could I check?

The controller orientation might override your pawn orientation.

Make sure that :

1 - Under Character (Self), UseController Rotation Pitch, UseController Rotation Yaw and UseController Rotation Roll are set to false.

2 - Under CharacterMovement, Use Controller Desired Rotation is set to false and Orient Rotation to Movement is set to true.

Or with C++ in your constructor :

bUseControllerRotationYaw = false;
bUseControllerRotationPitch = false;
bUseControllerRotationRoll = false;
UCharacterMovementComponent* const MovementComponent = GetCharacterMovement();
if (MovementComponent)
{
	MovementComponent->bOrientRotationToMovement = true;
	MovementComponent->bUseControllerDesiredRotation = false;
}

And make sure your blueprint doesn’t override these by clicking the yellow arrow next to the property.

4 Likes

Hi , I was really hoping that is all that it was, but unfortunately, it was actually already checked. Thank you though!

Oh yes it is definitely the child of the parent class I am using. I should have also figured because a lot of things like the camera boom, follow camera and axis movements are all effected with I change the code. Just not a lot of the orientation things. But by checking, it definitely is. Thanks though!

Here is my code in case you are interested. I did add that in there to no avail. I am actually starting to think something is wrong here. I have spent over two weeks scanning third person template vs mine, only things that are different are things like touch for jump and stuff. It should be accepting my orienttomovement. I also tried reloading the blueprint.

I figured it out! Thank you all for your help. I guess I don’t know 100% why this occured but even though bUseControllerRotationYaw = false; in my code, apparently in the character blueprint itself, the very top MyCharacter_BP (self) selected, I had to manually uncheck use controller rotation yaw, and that is all it was! Hopefully this can help someone else.

4 Likes

first thing,you have to make sure that you already have triggle (movement>root motion>allow physics rotation during anim rooot motion ).
then you have to set (add movement input) by control rotation and inputAxis value

Thanks a lot, dude! I had the same problem.

i have the same problem
Tick to cancel the part you said
it can rotate normally
thanks

I had the same issue. Selecting orient to character movement had no effect because i was making a character based off of my own class (which inherited from the ACharacter class). If you build something based off of a template this stuff should work right out the gate and with some changes in the BP detail menu you automatically get the rotations that you want. However, if your like me and built it off of a blank project, you will need to calculate the rotations in a function that returns the forward direction for your character.

Here is my code.

void AMainCharacter::CharacterForwardDirection(FVector& outForward)
{
FRotator rotation =Controller->GetControlRotation();
FRotator YawRotation = FRotator(0,rotation.Yaw,0);

// get forward vector in regard to the camera
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);

outForward = ForwardDirection;
}

this was ripped from a template and since I am making a side scroller I had no need for a right direction. If you need one for your game I would imagine that you would simply change the code to something like this.

void AMainCharacter::CharacterForwardDirection(FVector& outForward, FVector& outRight)
{
FRotator rotation =Controller->GetControlRotation();
FRotator YawRotation = FRotator(0,rotation.Yaw,0);

// get forward vector in regard to the camera
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);

const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);

outForward = ForwardDirection;
outRight = RightDirection;
}

You’ll want to call this in the function that you bind to your input to. In that function you’ll want to pass an FVector variable into its parameter. since its a pointer this will update your fvector outside of the function and then you can use the variable in your AddMovementInput function.

Example: AddMovementInput(ForwarDirection,PlayerInput.X);

For context here is what that function looks like in my class

void AMainCharacter::Move(const FInputActionValue& Value)
{
const FVector2D InputPlayerMovement = Value.Get();

//Print initial Input
if(GEngine)
{
const FString DebugMessageKey = FString::Printf(TEXT( “X: %f,Y: %f”), InputPlayerMovement.X,InputPlayerMovement.Y);
//GEngine->AddOnScreenDebugMessage(-1,15.0f,FColor::Red,DebugMessageKey);
}

if(Controller!=nullptr)
{
//Since its a side scroller all we need is the Forward Direction.
//const FVector ForwardDirection = FRotationMatrix(GetCapsuleComponent()->GetComponentRotation()).GetUnitAxis(EAxis::X);
FVector ForwardDirection;
CharacterForwardDirection(ForwardDirection);

  switch (WorldState)
  {

  case e_world_mode::InBridge:
  	//If in bridge move forward continuously without input.
  	AddMovementInput(ForwardDirection,PlayerMovementSpeed);
  	break;
  
  case e_world_mode::InIsle:
  	//Make the forward direction the direction the player is facing.
  	AddMovementInput(ForwardDirection,InputPlayerMovement.X);
  	
  	break;
  default: ;
  }

}
}

I am using enums in my game for world states so you can just overlook those and add it without those.

as a side note I am still learning so some of my practices and naming conventions might be distastful to some. If so, please inform me :]

you so good to solve my pain!!! Thanksssss!