Hello. I cant find a way to do the exact same thing in c++. Basically im making a 2d game and im not using the 2d slider template cause i wanna learn it in c++. So i want my character to rotate itself in the direction im moving stay in that direction util any other input. Hope it makes sense.
Returns controller for this actor.
GetWorld()->GetFirstPlayerController()->GetPawn()->GetController();
–
Implements a container for rotation information. All rotation values are stored in degrees.
const FRotator MyRotator = FRotator(0.f, 0.f, 0.f);
and
Set the control rotation. The RootComponent’s rotation will also be updated to match it if RootComponent->bAbsoluteRotation is true.
GetWorld()->GetFirstPlayerController()->GetPawn()->GetController()->SetControlRotation(MyRotator);
Hello. Thank you for replying. This is the problem im having now. If i press D(right) it moves right and faces right fine but if i press A(Left), it moves right again but faces left and as soon as i left the key A it faces right again. So character always moves in right direction. Also my root which is a capsule is inherited so i dont know how to access its babsouluterotation bool. This is the code for move right.
void AMyCharacter::MoveRight(float value)
{
AController* Controller = GetWorld()->GetFirstPlayerController()->GetPawn()->GetController();
FRotator Rotate;
if (value < 0)
{
Rotate.Add(0, 180, 0);
Controller->SetControlRotation(Rotate);
}
else
{
Rotate.Add(0, 0, 0);
Controller->SetControlRotation(Rotate);
}
AddMovementInput(GetActorForwardVector(), value);
}
Verify the value you are placing on your buttons in the “input”. Enter project settings-> input
check the “Third Person” project of c ++. There is all that explained.