Part 3: Creating Lanes

Christiane Snyder

This game will have three lanes that the player can teleport to while avoiding obstacles and collecting power-ups. We’ll start working on them by creating three planes named “Lane1”, “Lane2” and “Lane3” with the following transforms:











Inside of the Materials folder from the starter unity package, their is a texture named “Lines”. Create a new textured material (also named “Lines”) by right clicking on the project view of the Materials folder and selecting:


Create > Material

And selecting the following shader options inside of the material you create:

Unlit > Texture

Edit the Lines materials’ tiling fields so that it repeats 15 times along its length:


Finally, drag it onto your three newly created planes. After adding the lane’s texture, the scene should look like this:

While creating an endless runner, it’s important to have some type of texture on the ground below the player to act as a reference point to if they’re moving and the speed they are moving at. I made a striped pattern texture because it compliments the user’s constant velocity and is easily tailored space theme.

Now that the ground planes have a consistent texture on them to act a progress guide, they need to appear as if they are moving. There are a few approaches, including generating and deleting terrain during gameplay, moving and resetting the lanes position as the game proceeds and actually moving the player. All three of these approaches will create an unnecessary amounts of work for our purposes. To create the illusion of movement, we’ll move the texture on the lanes over time while keeping both the player and the actual lanes stationary.

Create a C# script named Lane.cs that will move each plane’s texture by a constant offset in its Update function:



Attach Lane.cs to all three lanes in the scene (Lane1, Lane2 and Lane3).


This endless runner experience will allow the player to teleport to each lane by looking at it and pressing the Cardboard viewer’s single trigger. To make the lanes respond to gaze input, have their attached Lane script implement the IGvrGazeResponder and its necessary functions.


Include a private GameObject variable named GvrMain that will reference your GvrMain in the scene, which contains the Main Camera. Inside the OnGazeTrigger() function, assign the GvrMain object a position relative to the lane this script is attached to teleport to a location above the selected lane.


After adding the lines of code above, all of the lanes functionality is complete.

If you were to build this project and run it on your mobile device, it would work, but it won’t work during testing in the editor because there is no touch input on your computer. Add a EventTrigger component to each Lane that maps the functions dependant on Gaze Input to mouse events.