Skip to main content

Lesson 2: Driving for Distance - Moving Forward and in Reverse

In this Lesson, you will create a VEXcode VR project that uses forward and reverse Drivetrain commands to knock down the first castle in the Castle Crasher Playground!

Castle Crashing Playground

Learning Outcomes

  • Identify how to use the [Drive for] block to drive the VR Robot a specific distance.
  • Identify how to change the parameter in the [Drive for] block to move the VR Robot forward and reverse.
  • Identify how to use the [Set drive velocity] block to set the speed of the drivetrain.
  • Identify the range of values used in the [Set drive velocity] block.

Create a New Project

A VEXcode VR project must be created in order for a VR Robot to move forward in order to collide with the first castle in the Castle Crasher Playground, then drive in reverse to return to the starting position.

Follow these steps to create a new VEXcode VR project.

  • Launch VEXcode VR at
  • Open the File Menu and select 'New Blocks Project'.
  • You will be prompted to select a Playground. Select the Castle Crasher Playground.Image of the Castle Crasher Playground
  • The Playground will open in the Workspace.Castle Crasher Playground

Name Your Project

  • To name your project, select the project name box.
    Vexcode Project


  • Enter the new project name Unit2Lesson2, and select “Save."
    Unit2Lesson2 Named

Drive Forward and in Reverse

Use the [Drive for] block to program a VR Robot to move forward to knock over the first castle on the Castle Crasher Playground.

  • Drag the [Drive for] block into the workspace and place under the [When started] block.
    Drive 200mm
  • Select the “Open Playground” button to launch the Castle Crasher Playground if it is not already open.
    Open Playground
  • Check to make sure that the Castle Crasher Playground is open.
    Castle Crasher Playground
  • If a different Playground opens, change to the Castle Crasher Playground. To change Playgrounds, select the Select Playground button.
    Select Playground
  • Select Castle Crasher in the Select Playground menu.
  • Select the “Start” button to test the project.
    VR Start
  • The VR Robot will drive forward for 200mm on the Castle Crasher Playground. Note that the VR Robot did not touch the center castle. The parameters in the [Drive for] block need to be adjusted so the VR Robot can drive further.
    drive forward
  • Select the “Reset” button to reset the Playground and move the VR Robot back to the starting position.
    Restart Feature

Select the Next button to continue with the rest of this Lesson.