Use Controller Desired Rotation Bug

I have a setup where the character uses orient rotation to movement while his velocity is 0, and when he starts moving the mode switches to use controller desired rotation. I am using enhanced input. But, when I am looking at the front of my character and then start moving, instead of turning 180 degrees he does a weird pivot.

(The animations are sliding, I will fix it soon)

@jomskarlsefni
Are you looking for the effect of turning entirely in place, without moving the character forward at all?
I think your combination of the two controllers could be making this effect. I don’t know how else it would be happening.
I hope this can help!
-Zen

1 Like

Hi Zen, yes I am looking for turning entirely in place. As shown in the video, the character turns around a point, not in place. Could you elaborate on what you mean by 2 controllers?
Thank you

It looks like you’re adding an input to a character locally ( relatively to its rotation), not relatively to the player controller, like it should be.

This is my c++ code for movement:

if (Value.GetMagnitude() != 0.f)
{
	//add movement in the direction
	AddMovementInput(GetActorForwardVector(), Value[1]);
	
	//add movement in the direction
	AddMovementInput(GetActorRightVector(), Value[0]);
}

Is there a function for adding movement to the controller?

This should work.

if (Value.GetMagnitude() != 0.f)
{
	const FRotator ControllerRotation(0.0f, Controller->GetControlRotation().Yaw, 0.0f);	
	
    //add movement in the direction
	const FVector ForwardDir = ControllerRotation.RotateVector(FVector::ForwardVector);
	AddMovementInput(ForwardDir , Value[1]);
	
	//add movement in the direction
	const FVector RightDir = ControllerRotation.RotateVector(FVector::RightVector);
	AddMovementInput(RightDir , Value[0]);
}

That worked, thank you.

1 Like