Menu
CoddyTech

Recap: Drone Pilot

Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 23 of 67.

challenge icon

Challenge

Easy

Fly the drone:

  • The arrows fly it left and right along x and up and down along z, at speed units per second, with the same speed on diagonals.
  • While Space is held it climbs at climb units per second; otherwise it sinks at climb units per second.
  • It never goes below the floor: its y stays at least 0.5.

The Inspector sets speed to 4 and climb to 2. Press Play and fly, then press Check.

Try it yourself

using UnityEngine;

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

    void Update()
    {
    }
}

All lessons in Unity Scripting Basics