Lesson 2: Change Parameters in the [Drive for] Block
The VR Robot did not touch the center castle in the last project. It needs to travel farther. Adjust the forward parameter, test it, and watch the VR Robot knock over the center castle!
- Set the distance the VR Robot will move by entering the value 800 in the [Drive for] block.
The [Drive for] block can accept decimals, integers, or numeric blocks. The units can also be changed from millimeters (mm) to inches.
Using Switch Blocks
To change the units of measurement of the Switch [Drive for] block from millimeters to inches, type over "MM" and replace this unit with the word "INCHES." Make sure you type units of measurement in all capital letters. As you type in the new unit of measurement, a suggestion for the parameter will appear. You can continue typing to fill in the command. You can also hit the enter key or the tab key, or click on the suggestion to populate the command.
-
Start the project.
-
The VR Robot will collide with the center castle and knock parts of it over.
-
Select the “Reset” button to reset the Playground.
The VR Robot now needs to return to the starting position. Use an additional [Drive for] block and change the parameters to make it drive in reverse to return to the starting position.
-
Add a second [Drive for] block to the VEXcode VR project, and change the direction from “forward” to “reverse.”
-
Make sure the distance value is the same as the first [Drive for] block, 800 millimeters (mm), in order for it to return to the starting position.
-
Select the “Start” button and run the project.
-
The VR Robot will move forward and backward for 800 millimeters (mm), returning to the starting position.
Note: You have successfully completed the first part of the Castle Crasher Challenge! Even if all four parts of the center castle are not completely knocked over, if they are slightly displaced, that is acceptable.
For Your Information
To make a VR Robot drive forward and reverse at different speeds, you can increase or decrease the drive velocity using the [Set drive velocity] block. The [Set drive velocity] block accepts a range from 0% - 100%. The default velocity is 50%. Changing the velocity will apply to any subsequent Drivetrain commands.
This is the Switch [Set drive velocity] block. Notice that when using Python commands, the numerical parameter is always written before the unit (PERCENT), separated by a comma.
Save Your Project
To save your project, select “Save to Your Device in the “File” drop-down menu.

Once saved, the project will appear in the Downloads folder of your device as a .vrblocks file.
Using Switch Blocks
To change the driving direction from forward to reverse while using a Switch block, type the word "REVERSE" in the parentheses.
A suggestion will appear for the REVERSE parameter. You may click on this suggestion or hit the enter or tab key to fill in the parameter. Make sure you set the distance parameter to 800 MM to match the parameter used in this Lesson's project.