Changing the axes of a joystick based on the position of the camera?

Hey guys, just want to get a sense if this is possible and if so how to accomplish it. I have an augmented reality application which uses a mobile device’s camera and a target to make a character appear on the floor. I have a joystick that controls that character. At the moment “up” on the joystick means “forward” to the character, no matter where the user is holding his camera. This feels natural when the character is facing directly away from the user’s camera. However it gets very counter intuitive when the character faces to the left, right, or directly at the camera himself. Is there a way to have the joystick change axes so that when say, the character is facing “right” that “right” on the joystick will cause the character to go “forward.” And then change dynamically should the user move his camera or the character faces another direction.

I hope that’s made sense. In short I’m hoping to base the movement of a character using a joystick based on the relative position of the camera to the character. If I’ve made a mess of this I’m happy to clarify.

Thanks for any assistance!

I assume you are using Vuforia. I’ve not spent much time with Vuforia, but apparently the is an option to rotate the object rather than rotating the camera (found this out from a UA answer, not personal experience). If you want your approach with the current setup, then this may work.

 dir = camera.transform.TransformDirection(dir);
 dir.y = 0.0;
 dir.Normalize;

‘camera’ is a reference to the Vuforia camera. ‘dir’ will be the movement vector as calculated from your joystick. I’m assuming you want to take the ‘y’ out of the movement, but maybe not.