Game Development: Week 03

  Exercise 3: Challenge 1 – Creating a 3D Plane Flying Game in Unity

For our third exercise in the Game Development course, we were given Challenge 1: to create a basic 3D plane flying game using Unity. After going through several tutorial classes and learning the fundamentals of 2D and 3D game development, it was time to put our skills into practice. This challenge required us to solve a number of tasks, from programming the plane's movement to making its propeller spin.

Challenge 1: Plane Programming

The goal for this challenge was to bring a 3D plane to life with smooth flying mechanics and a dynamic camera. Here's a breakdown of the steps we completed:

  1. Solve the Warning Issue: We began by fixing any Unity warnings that appeared while building the project to ensure a clean run.

  2. Make the Plane Go Forward: The plane needed to continuously move forward at a steady speed. I wrote a simple script to handle this movement, using Unity's Translate function to move the plane along the forward axis.

  3. Slow the Plane Down to a Manageable Speed: Initially, the plane's speed was too fast, so I adjusted the forward speed to ensure a more controlled and enjoyable gameplay experience.

  4. Tilt the Plane with Arrow Keys: To simulate realistic plane movement, the plane had to tilt when the player presses the up or down arrow keys. I implemented this using the Vertical axis to detect input and rotate the plane accordingly.

  5. Reposition the Camera Beside the Plane: The camera needed to be correctly positioned to follow the plane smoothly. By setting an appropriate offset between the camera and the plane, we made sure the camera always tracks the plane’s movement.

  6. Make the Camera Follow the Plane: A simple script was written to ensure the camera stays locked to the plane, moving along with it to give the player a continuous view of the plane in action.

  7. Create a Script to Spin the Propeller: Finally, to add a touch of realism, I wrote a script that spins the plane's propeller when the player presses the spacebar. The propeller rotates at a set speed and stops once it completes a full rotation, enhancing the plane’s look and feel.

The Code

I used three different scripts to complete this challenge:

  • PropellerSpin: Handles the propeller spinning when the spacebar is pressed.

  • PlaneController: Manages the forward movement of the plane and allows the player to control the tilt using the up and down arrow keys.

  • CameraFollowPlane: Ensures the camera follows the plane, keeping a fixed offset to maintain a stable viewpoint for the player.


Small issue:There will be a slighty angle change after everytime i spins the plane

This challenge was a great way to dive into Unity’s 3D environment and practice scripting for game mechanics. Stay tuned for more updates as I continue to develop my skills in Unity game development!

Comments