Every frame I can determine what direction the player wants to turn and move in with:
float hInput = Input.GetAxis("Horizontal");
float vInput = Input.GetAxis("Vertical");
float cameraRot = Camera.main.transform.forward.y;
I’d like movement to work in terms of camera orientation, not player orientation, so hInput=1 should always turn the player to face the same direction as Camera.transform.forward, vInput=1 should turn to face Camera.transform.right, and -1 on either axis should turn 180 degrees from 1 on the same axis.
I already have a function that alters the player’s yaw in world space degrees: it compares two floats, currentYaw and desiredYaw, and rotates the player until the two match.
Where I’m stuck is, what’s the easiest way to translate the two axes and camera facing into world coordinates? (The way I’m trying to get this to work, if camera.rotation.y==35, and the player holds the D key and nothing else, this would return 90 degrees (horizontal axis) + 35 degrees (camera rotation)=125, which when fed to my rotation script would turn the player until player.transform.rotation.y == 125 degrees)