Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SetControlRotation doesn't work for some reason with Unreal engine

My code:

APlayerController* controller = UGameplayStatics::GetPlayerController(this->GetWorld(), 0);
FRotator Rotation = Controller->GetControlRotation();
Controller->SetControlRotation(Rotation.Pitch + amount*5, Rotation.Yaw, Rotation.Roll);

The error I get:

error C2660, function doesnt accept 3 arguments

What is the reason for that ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SetControlRotation requires 1 argument of type FRotator, not 3 separate ones for the rotation components (pitch, yaw, roll).

This is the meaning of the error you get (error C2660, function doesnt accept 3 arguments).

You can fix it by constructing a FRotator object from the 3 components, like this:

Controller->SetControlRotation(
//--------------------vvvvvvvv--------------------------
                      FRotator(Rotation.Pitch + amount*5, 
                               Rotation.Yaw, 
                               Rotation.Roll));

Note that although FRotator is composed of the 3 components, it is not the same (from the C++ point of view) as the 3 components given separatly.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading