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.
asked Feb 15 '16 at 10:13 PM in C++ Programming
FVector::Rotation is a function, so that line should just be
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
answered Feb 15 '16 at 11:16 PM
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));"
answered Feb 16 '16 at 11:37 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here