Menu
CoddyTech

Recap: Drive the Cube

Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 13 of 85.

This recap puts the chapter together: a position set once in Start(), then moves and turns on every frame in Update(), scaled by Time.deltaTime and asked with Input.GetKey. A position is the object's center, and all code goes inside the methods' braces.

challenge icon

Challenge

Easy

Put the chapter together: place, drive and spin a cube.

  1. In Start(), place the 1 unit tall cube on the ground at x = -3, z = 0.
  2. In Update(), while the right arrow is held, move it right at speed units a second.
  3. While Space is held, spin it around y at spin degrees a second.

Press Play and hold the arrow, then Space. Then Check.

Try it yourself

using UnityEngine;

public class Driver : MonoBehaviour
{
    public float speed = 3f;
    public float spin = 180f;

    void Start()
    {
    }

    void Update()
    {
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Unity Scripting Basics

Practice on your own: Unity playground