I am trying to get my character to move forward relative to the y camera rotation. I am working with the oculus rift using a mouse as the input. I’ve done this:
if (Input.GetAxis("Mouse X")<0) moveLeft =true;
if (Input.GetAxis("Mouse X")>0) moveRight =true;
if (Input.GetAxis("Mouse Y")<0) moveBack =true;
if (Input.GetAxis("Mouse Y")>0) moveForward =true;
if (Input.GetKey(KeyCode.KeypadMinus)) Acceleration = Acceleration - .005f;
if (Input.GetKey(KeyCode.KeypadPlus)) Acceleration = Acceleration + .005f;
// Arrow keys
if (Input.GetKey(KeyCode.UpArrow)) moveForward = true;
if (Input.GetKey(KeyCode.LeftArrow)) moveLeft = true;
if (Input.GetKey(KeyCode.DownArrow)) moveBack = true;
if (Input.GetKey(KeyCode.RightArrow)) moveRight = true;
if (moveForward)
MoveThrottle += DirXform.TransformDirection(Vector3.forward * moveInfluence);
if (moveBack)
MoveThrottle += DirXform.TransformDirection(Vector3.back * moveInfluence);
if (moveLeft)
MoveThrottle += DirXform.TransformDirection(Vector3.left * moveInfluence);
if (moveRight)
MoveThrottle += DirXform.TransformDirection(Vector3.right * moveInfluence);
The keys work properly, however the mouse movement moves the character on a locked x and y axis no matter the camera rotation. I am very poor at coding so please explain thoroughly.
I think the use of books may be causing it. Use two floats, one for mouse x and one for mouse y. Then make a dead zone control, so it Is not too sensitive. Move by using the floats multiplied by altitude.
– HuskyPanda213