While relatively simple logic I’ve spent the last two days trying to figure it out and can’t for the life of me. I’m working with a custom adaption of the rolling template basing some of my code on that provided. One of the differences in control that I’m trying to implement is having torque added to the mesh in the direction that the camera is pointing, rather than simply along the X, Y axes. The pawn I’ve created has the same hierarchy as the one in the template (StaticMeshComponent → SpringArmComponent → CameraComponent) and I have all controls handled through a PlayerController as opposed to the the Pawn itself as is done in the template. Everything but my MoveForward() and MoveRight() functions work as expected. The two where torque should be applied to the StaticMeshComponent. What I can’t figure is how to use the Camera’s forward vector to apply torque to the StaticMeshComponent in the corresponding directions: MoveForward() - forwards and backwards relative to the Camera’s forward vector, MoveRight() left and right perpendicular to the Camera’s forward vector.
Here are the .h and .cpp file for this pawn. The code in MoveForward() (other than the if-statements) are my lackluster attempts at getting it to work, the block of commented code is split into different iterations with the use of multiple comment blocks/lines.
Any help figuring this out would be greatly appreciated.