Airplane control and procedural map in Unity with C#
Aalto’s Devlog #6 / 4th - 22nd September 2023
-
First steps into scripting with C#
-
Setting the basic controls of the aircraft
-
Using a grid and perlin noise to generate procedural landscape in front of the player
-
Turbo mode, Cinemachine cameras, intermitent trails of wind and camera effects. to achieve the final look.
The goal of this course was to have an introduction to C# scripting in Unity. I had no previous experience with coding, so I went through the basics of scripting and I worked on my own prototypes. This was a self-study course, so I followed tutorials and online resources to work on my own project. I also had help from my teachers, who challenged me to make the most out of my prototype. It was really interesting to dive into the programming side to see how scripts are developed.
Software Studies
About the Course
Airplane prototype video:
Introduction to C#
01
During the first week of this course I focused on learning the basics of C#. Since I had no relevant experience with C# scripting, I decided to use some of the assets that I had created in the past to replicate a simple 2D platform. It was an effective and simple way to test the spritesheets I created for our Indie Spain Game Jam’s Marzanna. One of the most interesting pieces of code to me was the one created to make the player follow the platform when standing on top of it. To make it work, you can make the platform a ´parent´ for the player. There is a problem with this, and it it that if you want to move the player on top of the moving platform, your speed will link to the platform’s and you character would barely move. This is fixed by separating the player's children state with the platform every time the player moves.
Very simple player controller and platforms made with C# in Unity
Script for the platform. Notice the player ‘parenting’ and ‘unparenting’ state when walking on the platform.
Script for player movement.
Airplane movement
After the first introductory days, I was ready to add new features to the platformer project. But, during the course of the following week, I started working on a pitch presentation for our Game Project course. Since I was already using Unity to learn C#, I thought it was a good idea to prototype a simple part of the game to show in the pitch presentation. My pitch idea was about a banner-towing pilot, and I made a simple aircraft controller and made it fly on top of one of my map’s sketches.
02
A couple of the pitch’s slides showcasing the airplane and free flight area
Part of the script controlling the airplane
Procedural ground
03
Add more features to the game. The terrain is generated randomly following a ‘Perlin Noise’ pattern and it is created taking into consideration the position of the player. The script checks if the player has a certain amount of squares in front of it. If it hasn’t, it will create one extra row before it. One of the features that I didn’t have time to implement was deleting ground behind you.
Scene view of the airplane flying. The terrain is being generated as the player moves.
Series of very simple tutorials that I followed to create the prototype.
Adding Details
During the last week of the course, I added some cool features to the airplane, like a turbo mode that is activated when pressing Shift. I also created two Cinemachine cameras that switch between the turbo mode. Additionally, I added trails to the wings that are activated when turning (they follow the direction of the plane), also when going up and down and in turbo mode. Finally I color graded the scene and added some camera effects to achieve the final result.
04
Before and after. The effects added in Unity were: Lens distortion, Grain, Ambient Oclussion, Depth of Field, Vignette and a good dose of Color Grading. Also the fog in the background helps hiding a bit the spawn of the terrain.
Final result
More from Aalto’s Devlog:
-
Untitled Penguin Game (1/3)
Period 2 - Game Project I
-
Airplane control and procedural map in Unity with C#
Period 1 - Software Studies for Game Designers
-
Game Jam: Mamapato
Period 0 - Introductory Game Jam