I'm having a few issues with a bit of game-logic. Right now I've got a setup that has the player use the new Samsung Galaxy S8 with the Gear-VR Headset + Gear controller to explore an environment. The current code is setup that the player can move forwards and backwards using the direction to which they're looking using a character controller and a calculation of the direction the camera is looking towards to move towards based on the 'touchpad' of the controller.
I have a horizontal and vertical axis (Based on the controller 'touch') that goes from -1.0 to 1.0 in a Vector2.
if (input.y > 0.0f || input.y < 0.0f || input.x > 0.0f || input.x < 0.0f) {
Vector3 direction = new Vector3(cameraObject.transform.forward.x, 0, cameraObject.transform.forward.z);
cC.Move(direction * walkSpeed * Time.deltaTime * input.y);
}
The above code translates the player forwards and backwards by calculating the direction the camera is looking at and moving 'towards' it, but what I also need is to 'strafe' to the left and right and can't seem to figure it out.
if (input.y != 0.0f || input.x != 0.0f) { ... }
but from the code in the brackets I see you don't even useinput.x
so if statement can be even shorter:if (input.y != 0.0f) { ... }
– Nika Kasradze