Player movement math, getting the right direction

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rogerdv

Im working in a 3D game for mobiles, and my first prototipe used one joystick to move the player, with a fixed, almost top-down camera. Then the game designer, after watching a third person camera tutorial, decided that it would be much better and dinamic if we add a second control to rotate the camera, and keep the first for movement. A mess, IMHO, but I have to implement it and test it. The problem is that I have tried some combinations and my math is wrong.

I have a scene with the player mesh (a sub-scene), and a pivot with the camera as child, to control camera movement and rotation. What I need is to use the Vector2 generated by the movement joystick to move the character, but considering that the pivot might be rotated. How can I calculate the right direction to make the character move “forward”, or back, side, whatever?