Recap: Drone Pilot
Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 23 of 67.
Challenge
EasyFly the drone:
- The arrows fly it left and right along x and up and down along z, at
speedunits per second, with the same speed on diagonals. - While Space is held it climbs at
climbunits per second; otherwise it sinks atclimbunits 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
1Your First Script
Hello, UnityPlace the CubeMove Every FrameTurn Every SecondSteer with the KeysRecap: Drive the Cube4Vectors
Adding VectorsDirectionsLocal and World SpaceDiagonal SpeedDistance Between ThingsVector3 Is a StructRecap: Drone Pilot7Project: Catch the Star
The CatcherA Falling Star5Transforms and Hierarchy
Parents and ChildrenScaleLook At ThingsMove Toward a PointRecap: Orbiting Moon