
Lets take a look at the final product that we will get when we finish this entire course!
Lets get our Project setup and learn how to use a handy little tool that is included with te Indie-Pixel framework.
In order for us to test out our Airplane physics, we need a scene setup to test within. In this video we are going to set up a scene that is for testing only, but will give us a clean environment to prove our flight physics.
In order to begin our Airplane Physics setup, we need to make sure our GameObject structure is in place and our Airplane model is ready to go.
With our Airplane model all setup, our prefab in place, and our GameObject structure completed, lets take a look at setting up the Colliders for our Airplane.
I always like to take a moment, before I dive into a new Controller and really think about the design of the code. I rarely just start coding. So lets walk through the process I use and hopefully itll inspire you and give you some ideas about how to go about designing your code.
Lets discuss what we are going to do in this section and the different items we will cover with regards to user input.
I wanted to show everyone how to install the completed Airplane Physics unity package, that can be downloaded in Lecture 8, into Unity 2018.3.1.
Now that we have a game plan in place for our Inputs, lets get our scripts stubbed in and ready for coding.
Namespaces and Variables are very important to our coding. so lets take some time to learn how to use them in our Airplane system.
Properties give us a certain amount of protection from outside scripts accessing data. So lets see how we can use them to pass the input data around.
Virtual methods, in C# are super powerful in that they let you override functional or extend functionality without having to re-write a bunch of code. Lets take a look at how to use them in our Airplane system!
Unity's Input Manager is our one stop shop for adding custom input mappings. This is especially important when supporting game controllers. So lets take a look at working with the Input Manager.
I love creating Editors inside of Unity. Not only are they fun to make but they are extremely powerful to end users. Giving them a visual way to interact with the code you created. It saves production time and repetitive tasks for your production team. Lets walk through creating a basic inspector editor for our inputs. This will give us a visual display of what our input values look like.
Now lets take a look at how we can use our Virtual method in our base input class and override its functionality to support the xbox controls.
Now that we have our Xbox controller input going, lets update the Inspector editor to support this new class.
In order to get our Xbox controls completed, lets add a couple more inputs to our Input Manager in Unity.
Ok, lets talk about what we are going to learn in this section.
Lets get our scripts stubbed in and understand why we are setting up our scripts the way we are.
One of the first glimpses at creating a re-usable system is going to be creating the Base Rigidbody Controller. This will be a script you can use for just about any Rigidbody Controller inside of Unity.
With our core scripts in place lets continue and create the Airplane controller script. This will begin to reveal the basics of inheritance in C#.
Weight plays a huge factor in Physics. In order to move a Rigidbody we need to apply a force that counteracts the objects weight. So knowing the weight of our airplane will help us create a more accurate Physics System.
I love to make my systems easy to use for other people, especially in a production environment. In this lecture we are going to make it so the Airplane setup is simply created from a single menu option.
The Airplane Engine is where everything begins in the Physics. In order for a plane to maintain flight it needs speed. In order to create speed we need power created by an engine and propeller. Lets quickly go over the topics we are going to cover in this section.
Before we do a deeper dive into creating our engine script, lets learn how to apply forces to a rigidbody.
Lets get our scripts stubbed in for our Airplane Engine system.
With everything in place lets hook up the meat of the engine code.
In order for our Airplane to roll on the ground we will need to manipulate the wheel colliders, in Unity, directly.
A great way to allow designers to quickly and easily test out different physics setups, we can create Animation Curves, instead of providing just float values to the Inspector.
OK, so lets go over what we are going to learn in this section.
Lets get our Propeller scripts all stubbed in and ready to go for coding.
In order to rotate our Propeller, we need to know how fast the engine is spinning. Lets take a look at how to convert RPM's into Degrees Per Second.
Lets have a little fun and learn how to set up the graphics for our Propellers.
A cool old school trick is to blend different blurred propellers based off of the rotation speed. This gives the propellers a way more realistic look when in flight.
Its always a good idea to learn how to manipulate materials inside of Unity. It opens a whole new world of FX and tricks that save you time and get the job done. lets learn how to swap textures in a material.
At the heart of the Airplane system, we have our Flight Characteristics. Lets take a look at what we are going to learn in this section.
As usual, lets get our scripts stubbed in before coding so we know everything is hook up correctly, from a high level.
In order for us to be able to calculate lift, drag and many other components of flight physics, we need to know how fast we are going. So lets take a look at calculating our forward speed.
Now that we are on our way to creating a full Physics system, lets take a moment to update our Throttle to a sticky throttle so it mimics more of how a real airplane throttle works.
Lift is the first and one of the most important Forces that acts upon a plane. So lets take a couple minutes to understand how lift is created in the real world.
Now that we have a better understanding of how lift is generated in the real world, lets take a look at how to create it in Unity using Rigidbodies and forces.
Once again we will employ an Animation Curve property to control our lift power over the amount of speed we are generating from the engine. This makes it easy and visual for Designers to set up new flight models.
Drag is a very important force when working with Rigidbodies and Physics in Unity. This force keeps things relative,ly stable and controllable. Without it we would simply spin out of control or float off into space. Lets take a look at how drag is integral to our Airplane Physics.
When flying a plane your angle of attack is very important to the performance of your airplane. The steeper your angle of attack is the less lift your produce. Menaing you cant just pull the plane up 90 degrees or it would fall into a spin and possibly end up in the ground. So lets take a look at how we can further add some realism to our flight physics by incorporating the angle of attack.
When working with rigidbodies in Unity, we almost always want to give more direct control over the final simulation of the physics. Unity's Rigidbody gives us ways in which we can interact with it almost like directly working with the Transform class. So lets take a look at that.
Pitch is how we get an airplane to go up and down. Very important in flying a plane. So lets get our Pitch control in place.
Roll is also very important to flight as it is one of the main ways we get the airplane to turn. Lets get it hooked up in our system.
The rudder of the plane creates a force called Yaw. It allows us to make small or large direction changes but is used very sparingly when flying a plane. So lets get it hooked up to our system.
To close out this section we will make the plane turn slightly when we roll. This will add the final level of realism to our plane that really makes it feel like you are flying a real world airplane.
One of the more important components to a controller system, inside of Unity, is the camera. This is how the player views the world and controls the vehicle. So lets talk about what we are going to do for our Airplane camera.
Lets get our Camera scripts stubbed in and ready for the code.
To begin our camera system, lets take a look at how to create a basic but useful follow camera.
when I was first developing the camera for the Airplane, I noticed that I really needed to have the camera adjust its height when it got closer to the ground. Mostly when the Airplane was on the ground. So lets take a look at how to do that.
The control Surfaces of an Airplane determine how the airplane navigates through the air. Since we have the physics working, lets get our control surfaces working so it looks like the graphical representation of a control surface is actually manipulating the Airplane.
As usual, lets get our Script stubbed in so we know that it is working with the entire system.
With our Scripts stubbed in, lets put in the meat of the Control Surface Script.
Now that we have our script all coded up, lets hook up the rudder and test out the scripts modularity!
Lets get the ailerons hooked up now and finish out this section! :-)
Lets quickly go over the items we are going to cover in this Wheel section.
To add some more realism and control over our Airplane, lets rol and position the wheels according to speed and the Suspension distance.
If we didn't have brakes we would be in real trouble! So lets learn how to add braking to our wheels.
Steering is also very important, in the sky and on the ground. Lets learn how to steer our airplane on the ground using the wheel collider.
Have you ever wanted to build your own Airplane Physics using the Rigidbody component in Unity 3D? Do you want to know more about setting up modular code to make your workflows faster and more re-usable? If so, this course is for you! Throughout the contents of this course you will learn how to create a fully functional Airplane Physics model.
In the course you will learn to build the full physics flight model, how to animate the propeller, how to setup inputs, how to build a dynamic airplane camera, how to animate all the control surfaces of the plane, and more!
By the end of this course you will have your very own Flight Physics System that you can use for your own flying games.
By Purchasing the Course you get the Following:
The Complete Airplane Physics Code
Two Airplane Models, the Indie-Pixel Plane and the F4U Corsair
Complete UI kit to create the Instrument UI for the Airplane