How to make a character rotate 90 degrees when some condition is true?

Hi, I want to make the first person character rotate 90 degrees every time when some condition is met.
The rotation doesn’t need to smooth. I used SetActorRotation( ), but it has no effect.
For example:

if (EvenSquare){
FRotator Rotator = GetActorRotation();
Rotator.Yaw += 90.f;
SetActorRotation(Rotator);
}

The actor here is a character in the first person template.
What have I missed?

Does it still have an effect out side the if statement ?
Also you should always add DeltaTime to it like:

 Rotator.Yaw += 90.f * DeltaTime;

It has no effect even outside the if statement. About your suggestion, my code for rotation is a void type method. It is not inside the Tick() function so no DeltaTime is associated with it.

Maybe try using AddControllerYawInput(90.f) instead of setting the character actor rotation.

Thanks it works!

You’re welcome :wink: