In VR, movement is usually done in 2 ways. Either continuous movement, or teleportation. This post will be part 1 of a multi-part blog post on how movement is done. Since our future game will be done via continuous movement, we'll be implementing a continuous movement script in order to move our character and camera.
We're going to make sure that our XR Rig camera set up has a character controller component so that we can access it. We'll also keep the character controller component default.
Let's start talking about the code.
We'll want to create a public variable and then grab the CharacterController from start.
Next, we'll want to listen to input from a given device. We'll need to create a public XRNode inputSource and a private Vector2 input axis. We will put it in our update function so that we can constantly ask if the input is constantly being entered. First, we'll try to get our devices and let the inputSource be our left-hand controller. Next, we'll try to listen to the device's input.
For the actual movement for the character, we're going to do the movement in the FixedUpdate function so that when unity updates the physics of the game, it'll also update the character. We'll grab the direction of the remote and apply the movement by the value. We can also add a speed variable so that we can better adjust the speed.
This is a simple method to move our camera/character; however, there are a few problems. We won't fall to the ground after climbing a slope, we aren't going straight to where our camera is facing, we will clip into walls because our character controller is smaller than our camera, and we can't spin. We'll fix these issues in the upcoming blog posts.


