Lesson 3: Turning the VR Robot
Now that you have knocked over the first castle in the Castle Crasher Playground, you will need the VR Robot to turn to knock over another. This Lesson will walk you through the steps to turn the VR Robot and knock over two buildings on the Castle Crasher Playground.
Learning Outcomes
- Identify how to use the [Turn for] block to turn the VR Robot right or left.
- Identify how to use the [Turn to heading] block to turn the VR Robot to a given compass heading.
Rename the Project
- If the previous lesson’s code is not already loaded, load the Unit2Lesson2 project.
- Rename the project by selecting the project name box.
- Enter the new project name Unit2Lesson3, and select “Save.”
Turn Right or Left
The [Turn for] block rotates the VR Robot a given number of degrees. This example will have the VR Robot drive forward to knock over the center building, reverse back to the start, then turn and knock over the building in the bottom right corner on the Castle Crasher Playground.
For Your Information
To make a VR Robot turn at different speeds, the turn velocity can be increased or decreased using the [Set turn velocity] block.
- Drag in the [Turn for] block and attach it beneath the [Drive for] block. Set the parameters of the [Turn for] block to turn right 90 degrees.
- Note: This project has the [Set drive velocity] and [Set turn velocity] blocks added and set to 100%. These are optional blocks.
- Note: This project has the [Set drive velocity] and [Set turn velocity] blocks added and set to 100%. These are optional blocks.
- Drag in the [Drive for] block and attach it below the [Turn for] block. Set the parameters of the [Drive for] block to 700 millimeters (mm).
- Select the “Open Playground” button to launch the Castle Crasher Playground if it is not already open.
- Select the “Start” button to test the project.
- Watch the VR Robot drive forward and collide with the center building before reversing back to the start. The VR Robot will then turn right 90 degrees and drive forward to collide with the building at the bottom right corner of the Castle Crasher Playground.
Using Switch Blocks
This is the Switch [Set turn velocity] block. Simply replace the numerical value by typing in a different number to change the block's parameter.
To convert an entire stack of VEXcode blocks to Switch blocks, simply select a VEXcode block and choose, "Convert Stack to Switch Block." The image below displays this Lesson's project as a Switch block. Each VEXcode block is converted into a Python command, and each command is listed inside one Switch block.
Select the Next button to continue with the rest of this Lesson.