Welcome back.
OK.
So let's go and get our ailerons hooked up on the plane.
It's going to be exactly like the rudder on the elevator.
But I wanted to step through each process so I didn't skip over anything for you guys so let's jump
over into unity and get going.
OK.
So let's go and create another game object underneath our control surfaces here and we're going to call
this art Ayler ohms.
OK.
And we're going to assign our control surface grip to it then set the type to aileron will sit center
angle it will keep it at 30.
We'll tweak all these things when we start polishing.
And now if we take a look at the ailerons.
All right we want them to rotate around the x axis as well.
So the default is good.
So let's go back here.
Set the.
So we're going to call this the left aileron actually.
We're going to do them individually so we assign the left aileron game object and we'll give it that
smooth speed of forward.
So they're all consistent for now.
It's always good to have a consistent starting point before you go and make each one really individual
and unique OK.
So that is that.
And let's go and just duplicate that.
And we'll call this the right aileron and was signed the right aileron deem object to the control surface
graphic there they're perfect.
All right so let's test this out.
Now this is an enemy right.
Right off the bat.
That's why I'm actually doing it this way.
So as I roll the plane Oh and I forgot to assign it to our airplane controller here so another good
reason to create an automated set up.
So what I want to do is I need to add those to control surfaces to the airplane controller so it can
handle them.
So wouldn't it be nice to have a button down here that just goes and looks for control surfaces in the
hierarchy.
We'll get to it.
No worries.
OK.
Let's try that again I'm going to leave my maximize on play off there.
Let's play.
All righty so now as I rotate you can see the ailerons are going up but they're both going up.
And that's not how ailerons work.
So the other ones work.
One side goes up and the other side goes down.
And that's how we get our airplane to roll.
So the left hand there on in this case I believe needs to be negative and the right aileron is correct.
So let's test that again.
Pretty easy fix.
I like to create modular scripts like that.
And then there we go so let's test this out and fly around because we now have just about all of our
control surfaces created perfect won't cause too much drag Dragonair
little too much there.
Let's try this one more time.
All writing up pitch up gets down there and then pitch up.
Let's get some more outs before we start testing out there.
There we go.
Beautiful.
All right so let's start Ternan all of our control surfaces are all working.
I could really make this thing go into a spin.
Is exactly how you crash.
All right.
So that is that's a let's talk about what we learned throughout this section.
OK.
So I thought this was a pretty cool section because we really got to focus on a single script where
we were able to use that single script to take care of a lot of functionality on a honor airplane whereas
you know I've seen before in other people's you know setups that they try to take care of all the control
surfaces and one script that you know treats each control surface differently and it process processes
the code differently but really when you take a look at it and try to find the similarities between
the two those control surfaces all we really need to do is rotate them so it's a great place to create
a nice modular script and keep our code minimal but still accomplish the same tasks.
So how to do that.
We understood how to rotate objects using quaternions and we learned how to take a vector and convert
it into a core turning using the quaternion Euler method which is comes in handy a lot.
All right.
Because trying to do quaternions in your head or you know even the math for quaternions is quite complex
so it's really nice that you have the ability inside of unity to take a vector right because it's much
more easy to understand you know x axis y axis z axis angles.
Right.
And we can just take that vector and then pump it into attorney and method and it just pops out of court
or turning rotation for us so then we went and smoothed out the rotations using again that slip method.
So it's used a lot throughout the airplane set up in here and that makes everything just feel much more
realistic.
OK.
So that is that let me know if you guys have any questions and I'll see you in the next section.