Skip to main content

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.
    Rename Project
  • Enter the new project name Unit2Lesson3, and select “Save.”
    Unit2Lesson3 Named

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.

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.

turn velocity
  • 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.
    1. Note: This project has the [Set drive velocity] and [Set turn velocity] blocks added and set to 100%. These are optional blocks.
      add right 90
  • 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).
    right finished
  • Select the “Open Playground” button to launch the Castle Crasher Playground if it is not already open.
    Open Playground
  • Select the “Start” button to test the project.
    Start
  • 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.
    turn right

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. 

turn velocity

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. 

switch stack

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