How do I move in the direction the pawn faces instead of the camera
I'm starting from the c++ third person start and am trying to change the way movement works a bit. What I want to happen is the character will rotate either left or right using the a and d keys and then pressing w will make the character move in the direction the mesh is facing. I want the player to have full control over the camera at the same time, so that no matter where they face it the character will still move where the mesh is faced. It seems that everything is relative to the camera, however, causing the character to spin if I attempt to move it in the direction of the mesh. Any idea how I can fix this? I don't want to separate the pawn and camera, just set the controller to rotation to be the same as the mesh.
asked Apr 03 '17 at 12:52 AM in C++ Programming
It sounds like your camera is inheriting controller rotation and your character is not. If you want the camera to rotate with controller input and the character to move without the camera this is fine. I think your code is very close, but you want to move in the direction of the character's forward vector not necessarily the character mesh's forward vector.
If you are not already using a SpringArm, you may want to look into attaching one to your character and then attaching your camera to the SpringArm. A Spring Arm will help you decouple the code for your character's movement from the camera movement, and "automatically control how the camera handles situations where the it becomes obstructed by level geometry or other objects in the level." Here is some more information about that:
answered Apr 05 '17 at 12:47 AM
Mind giving a screenshot of the code that doesnt work as intended? Might be easier to help explain how it should be done. For now all i can say is to use the pawns forward vector.
answered Apr 03 '17 at 05:41 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here