Having to call the same function multiple time in order for it to work

This is one big weird issue. Take rotation for example: say I have Roll rotated my character, and I want to reset the roll rotation to 0.

The normal way to go about it would be:

APlayerController* pc = Controller->CastToPlayerController();
pc->SetControlRotation(FRotator(pc->GetControlRotation().Pitch, pc->GetControlRotation().Yaw, 0.0f));

However, that won’t work. The function is executed, however no rotation takes place. So I decided to try something else:

APlayerController* pc = Controller->CastToPlayerController();

while (pc->GetControlRotation().Roll != 0.0f){
pc->SetControlRotation(FRotator(pc->GetControlRotation().Pitch, pc->GetControlRotation().Yaw, 0.0f));

And usually after 2-3 calls, the roll gets to be 0.

I’m using the code in the Tick method. I’m obviously not executing it every time tick gets called, but I am trying to execute it when roll !=0.
In the end, I tried debugging and went through the method calls, all looks fine except the fact that the rotation only really takes place after the second, third or forth call.

Have you tried yaw instead, just to test whether this is a roll-specific issue?


I did. Also, this happens with the MoveRight method in the fps sample. In some places it works right away, in others, I have to call it multiple times in order for the character to actually move…

I’ve never heard of anything like this

When I get weird issues, I often find it best to start over, and usually I end up with better results / find out my issue

I recommend starting a new C++ project, testing just this issue, building only required framework to test this issue

and if your issue persists, at that point you could post your test project on Answerhub to get it reviewed.


Ok so I created a new c++ project and tested, and focused only on moveright. In the original code I was calling move right with values between 10-15…

If I call: MoveRight(-10000000); it barely moves a little… what does this mean?
Note: I call MoveRight in other places with small values and the movement can really be noticed.

Also, the SetRotation seems to be working now.

“Note: I call MoveRight in other places with small values and the movement can really be noticed.”

So smaller values DO show dramatic movement? Great!

Why do you need such a large moveright (moveleft really) amount?

Instead of a large amount all at once:

  1. put your moveright in a tick function or a timer and have it operate over time,

  2. and using smaller numbers you will get the end result of speed that you want.


I used the large number to see if it actually does what its supposed to. I started with 100 and went higher and higher, yet it was no real difference in motion.

use this instead

MyCharacter->CharacterMovement->Velocity += YourDir * YourSpeed;

FVector YourDir = the world space direction to move in
float YourSpeed = the magnitude of the direction vector.

and let us know if that works for you, so we know whether it is related to your use of MoveRight or if it is something else

an example direction:


example speed


So, it is related to MoveRight. Using the code above with a value of 10000 significantly moved the character. However calling MoveRight with a value of 10000 did pretty much nothing.

Also, I might’ve forgotten to say something important: I have my character rolled about 80 degrees when I’m calling MoveRight. Now I thought that was the problem(when I called moveRight, the character would not only try to move right, but up too, since the X axis was now rotated upwards). But then I looked at the MoveRight code and saw that it only uses Yaw rotation to get the right vector, so the Roll wouldn’t matter.

In the end, I saved the initial roll in a float, set float to 0, called addmovementinput() with the direction vector and then set the roll back as it was. Surprise, but again, no visible movement!..

What could the problem be?

I dunno naotom, in the case of project specific issues just find a project specific solution you enjoy, I"ve offered you my solution already as mentioned above :slight_smile:

I haven’t seen anything like this before. It’s weird that the ControlRotation issue went away when you switched to a new project. Can you think of anything you did differently? Were you overriding SetControlRotation or GetControlRotation anywhere? Did you debug into the actual SetControlRotation() function to see why it may not have changed the value for Roll?

Does MoveRight work if you don’t apply the 80 degree roll? In the first person template, “right” is relative to the actor rotation, not the control rotation, so this might make a difference. Also make sure you have the character movement component set up correctly in the first place in the default state, so that you aren’t stuck in some geometry at startup and are able to normally move. Then try making your changes to see how it goes. You could try to put a breakpoint in UCharacterMovementComponent::TickComponent() around where Acceleration is computed from the input vector (which MoveRight affects):

Passing anything over 1.0 to MoveRight shouldn’t really make a difference, since the size will be normalized to 1 (see UCharacterMovementComponent::ScaleInputAcceleration()).

Acceleration = ScaleInputAcceleration(ConstrainInputAcceleration(GetInputVector()));

Then also confirm in CalcVelocity that the Acceleration is being applied to Velocity.

Lastly, remember that Character / CharacterMovementComponent only really support vertical capsules at this time, so actually rotating the capsule 80 degrees may produce undesired behavior. It’s possible the rotated capsule combined with the fact that its using actor rotation (mostly pointed at the floor in this case) to move will try to push the capsule into the floor for the most part.