Setting player rotation using gampad input axis

I am trying to recreate behavior found in the “Twin Stick Shooter” tutorial series in C++, but have hit a wall when it comes to rotation.

For reference here is the blueprint I am trying to recreate in C++:

The following is the code I have currently. It gets the LookUpAxis and LookRightAxis value from a SetLookUpAxis() and SetLookLeftAxis() function that is called through the InputComponent->BindAxis lines (Not shown in the image but included in the ‘SetupPlayerInputComponent’ function).
No error lines are shown but this does produce the error “left of ‘.X’ must have a class/struct/union”. I have tried treating it like a traditional function by typing it as .X() but that does not work.


Any help or ideas as to how I could do this better would be greatly appreciated.

Thanks for your suggestion but unfortunately it was not the solution. I am only looking to rotate the “Weapon” object by the Pitch value, so the player essentially points in the direction they wish to fire. Using AxisVector.Rotation() in the SetRelativeRotation() function did something quite different.
Also the “SetComponentRotation” function you suggested is not part of the UPaperFlipbookComponent class, which is why I decided to useSetRelativeRotation instead.

Right now I have the player class setup to have two UPaperFlipbookComponents, one (inherited from APaperCharacter) for the player sprite and one that I added to show the weapon. The second flipbook is the only one I want to rotate around its origin with player input.

FVector::Rotation is a function, so that line should just be

const FRotator RotationValue = AxisVector.Rotation();

and that gives you the FRotator you want to pass in to SetRelativeLocation (this is assuming AMyPaperCharacter is never rotated, I would probably use SetComponentRotation instead). The function should look something like

FVector AxisVector = FVector(LookUpAxis, LookLeftAxis, 0.0f);
const float AxisVectorSize = AxisVector.Size();

if(AxisVectorSize > 0.25f)

Oh, it’s SetWorldRotation that I was thinking of, it seems there’s some inconsistency with the naming since the getter is called GetComponentRotation.

Anyway, looking at the code for the GetRotationXVector node in that blueprint it’s just a call to vector.Rotation() so I’m not sure why it’s not working for you. I haven’t used Paper2D that much so hopefully someone else can help.

I managed to get the results I was looking for by only using the .Yaw value of Rotation() and applying it to the weapons pitch by using “Weapon->SetWorldRotation(FRotator(AxisVector.Rotation().Yaw, 0.0f, 0.0f));”