Challenge 1 - Plane Programming

Tutorial

·

Beginner

·

+10XP

·

30 mins

·

Unity Technologies

Challenge 1 - Plane Programming

Challenge Overview:

Use the skills you learned in the driving simulation to fly a plane around obstacles in the sky. You will have to get the user’s input from the up and down arrows in order to control the plane’s pitch up and down. You will also have to make the camera follow alongside the plane so you can keep it in view.

Challenge Outcome:

  • The plane moves forward at a constant rate
  • The up/down arrows tilt the nose of the plane up and down
  • The camera follows along beside the plane as it flies

Languages available:

1. Introduction to Challenges

U1.Challenge1.Intro

2. Challenge 1 Overview

CWC_U1.C1

  • Open your Prototype 1 project
  • Download the Challenge 1 Starter Files, then double-click on it to Import
  • In the Project Window > Assets > Challenge 1 > Instructions folder, use the "Challenge 1 - Instructions" and Outcome video as a guide to complete the challenge

3. The plane is going backward

  • Make the plane go forward

4. The plane is going too fast

  • Slow the plane down to a manageable speed

5. The plane is tilting automatically

  • Make the plane tilt only if the user presses the up/down arrows

6. The camera is in front of the plane

  • Reposition it so it’s beside the plane

7. The camera is not following the plane

  • Make the camera follow the plane

8. Bonus: The plane’s propeller does not spin

  • Create a script that spins the plane’s propeller

9. Hints

  • Make the plane go forward
    Hint - Vector3.back makes an object move backwards, Vector3.forward makes it go forwards
  • Slow the plane down to a manageable speed
    Hint - If you multiply a value by Time.deltaTime, it will change it from 1x/frame to 1x/second
  • Make the plane tilt only if the user presses the up/down arrows
    Hint - In PlayerControllerX.cs, in Update(), the verticalInput value is assigned, but it’s never actually used in the Rotate() call
  • Reposition it so it’s beside the plane
    Hint - For the camera’s position, try X=30, Y=0, Z=10 and for the camera’s rotation, try X=0, Y=-90, Z=0
  • Make the camera follow the plane
    Hint - In FollowPlayerX.cs, neither the plane nor offset variables are assigned a value - assign the plane variable in the camera’s inspector and assign the offset = new Vector3(30, 0, 10) in the code
  • Bonus - Create a script that spins the plane’s propeller
    Hint - There is a “Propeller” child object of the plane - you should create a new “SpinPropellerX.cs” script and make it rotate every frame around the Z axis.

Complete this tutorial