Challenge 1 - Plane Programming

Tutorial

·

Beginner

·

+10XP

·

30 mins

·

(32631)

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:

Overview Video

1. Challenge 1 Overview

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

2. Warning

When you import the challenge into your project, it is supposed to have bugs.

The purpose of the challenge is for you to fix those bugs, which are listed below. There are also hints at the bottom of the page to help you if you get stuck.

If you cannot fix the bugs and wish to delete the challenge files from your project, in the Project window, right-click on Assets > Challenge 1 and select Delete.

Good luck!

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
Optional Step

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 PlaneController.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 FollowPlane.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 - Make the propeller spin
    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.
Optional Step

10. Want even more challenges?

If you want, you can challenge yourself even more by attempting to add special bonus features to your main prototype, which range from Easy to Expert in difficulty.

These extra bonus challenges are entirely optional. If you are not interested and just want to continue with the course, simply mark this step complete and move on to the next tutorial.

If you are interested, check out the Bonus Feature tutorial and remember to return here when you're done to keep learning!

Complete this tutorial