Menu
CoddyTech

Recap: Drone Pilot

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

This recap puts the chapter together: a direction built from the axes, made one unit long with .normalized, named directions such as Vector3.up, and a position changed through a copy.

challenge icon

Challenge

Easy

Fly the drone: the arrows steer, Space climbs.

  1. In Update(), move it by the raw axes (Horizontal on x, Vertical on z), .normalized, times speed * Time.deltaTime.
  2. While Space is held, add Vector3.up * climb * Time.deltaTime; otherwise Vector3.down times the same.
  3. Keep its y at least 0.5f, through a copy of the position.

Press Play and fly: it climbs on Space and sinks to the floor. Then Check.

Try it yourself

using UnityEngine;

public class Drone : MonoBehaviour
{
    public float speed = 1f;
    public float climb = 1f;

    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