All right so one of the first things that I want to polish up in this particular course is the actual
control surfaces.
So currently the control surfaces still provide for us even when the plane is just sitting still on
the runway.
So what we want to do is we want to actually base their efficiency off of the speed of the airplane.
Right.
If the airplane isn't producing any sort of air across any of the control surfaces they shouldn't actually
be moving the plane around even though it looks kind of cool.
But let's focus on building a really tiny system around controlling the control surfaces for US based
off of the speed.
All right so what we want to do is we want to make sure that the control surfaces don't produce any
sort of torque force when we're just sitting on the runway like we are right now.
So just to give you an example and hit play and if I were to move around any of the control surfaces
you can see that the plane is moving like crazy.
All right.
That's just because those torque forces are affecting the rigid body.
OK.
And we don't want that we want that to be based off a speed so the faster that we're going the more
air is traveling over all the control surfaces and so their efficiency in being able to torque the aircraft
or roll or pitch or yacht the aircraft becomes greater with speed.
OK so all we need to do is we need to go into the airplane characteristics and add a little bit more
code to control that force that torque force that we are creating with the control surfaces so I'm going
to double click on the airplane characteristics script to open it up inside of Monat develop over here.
All right.
And if you remember we are calculating the miles per hour but we're also calculating the normalized
miles per So zero to one value based off of whatever we input as the max mph sorry the max mph up here.
OK.
So we can do is we can utilize that and create another curve to allow us to modify how much torque force
is being created by those control surfaces based office speed.
So what I want to do is I'm going to come down here to the control properties.
All right.
And I'm going to add another animation curve.
So we're going to do an animation curve.
All right we're going to call this the control surface efficiency.
There we go.
All right.
And I'm going to initialize that to a new animation curve that ease in ease out.
And the first values are going to be the time starts and the value starts at zero and zero.
Want those two to be at the zero position and the time and and value end is just going to be one in
one because we want a by between 0 and 1.
OK.
So I'm going to copy this particular variable name up here.
All right.
And what I want to do at this point is create a new method that is basically responsible for producing
this efficiency value.
OK.
So we're going to basically say handle control surface efficiency.
Okay.
And that's going to be our method that we need to create.
So I'm going to come down here and right above the handle pitch method.
I'm going to create another method that is really just going to be responsible for processing this efficiency
curve.
So what we should do is make an I should actually rename this right here.
Just notice there a little typo there so let's just make sure that we
take care of that.
OK.
So what we want to do is we want to create another private variable up here and this is going to be
the the final value that's output from this particular calculation.
So it's going to be a float value.
And I'm just going to call it the C-s efficiency
value or something like that.
I mean you can call whatever you want and we should probably make that lower case.
All right.
So I want to copy this particular value.
And the reason why I'm doing this is because I want to be able to utilize this value in other methods.
For instance the pitch the roll and the yeah.
All right I'm going to multiply this final value to modify our pitch torque force or roll torque force
and or your torque force.
All right.
So what I'm going to say is that C-s efficiency value variable is equal to our control surface efficiency
curve evaluate because we want to evaluate this particular curve based off of some normalized number
from 0 to 1.
All right.
And that normalized number is going to be that normalized mph.
So what this is saying is when as we reach our maximum miles per hour we're going to get a value of
one if we are literally at 110 miles per hour which is what this is.
And I believe you know 110 miles per hour we're going to get a value of 1 out of this curve.
OK.
If we're at zero miles per hour we're going to get zero.
So this is a great way now to control our control surface forces based off of speed.
So I'm just going to multiply each one of these torque forces that were producing the pitch the role
on the air.
By this C-s efficiency value.
All right.
And the reason why I'm doing all this is because or at least the reason why I created this single method
is because I don't want to have to calculate the curve for each one of these forces.
I just want to do it once and by doing this it allows you to then manage that particular logic in one
spot instead of having to manage it in three areas.
OK.
So again I just want to multiply this guy by the C-s efficiency value.
Now the bank is controlled by our roll values.
Ok so that roll angle.
So we don't need to multiply it because for now rolling at all we're not going to be banking at all.
All right just these major torque forces that we're producing with the control surfaces.
All right.
So with that in place let's go back and unity and check this out.
OK.
So I'm going to go and select the airplane.
The object there because our characteristic script is on that route object and we have this ease in
our curve.
So as we approach 110 miles per hour we're going to get a value one.
And as we approach the zero we're going to get a zero.
All right.
We're around 55 miles an hour we're going to get point five.
OK so this should actually remove all the torque forces when we're just sitting there because we're
getting a value of zero.
So let's test this out.
All right so I'm going to start to manipulate all control surfaces.
And in fact we are going to go out the tail is moving because I did a little bit of throttle there and
it is also controlling steering so that's why I turn.
But you can you can see that our ailerons in our elevator and our rudder aren't necessarily created
and the torque forces.
But if I were to throttle up for now going to start to get the forces safely down so you can go and
you can if you can just like the lift curve.
This is an efficiency type of curve.
It's like a coefficient type of curve.
OK.
I like to call it efficiency it's just easier for most people to understand it's how.
How efficient are the control surfaces over some sort of value that changes like time or speed.
OK.
Or you know height for airplanes an air density and pressure all that kind of stuff.
Angle of attack.
Those are all values you can normalize to create these curves that praties different results.
All right and that's why this is working and it's also why it's a great way to use these animation curves
for your control type of objects here like vehicles inside of unity because it really allows a designer
a user whoever's setting up the system to really refine the system.
So they're like something.
So now we have the tools are yes.
But as I start to throttle down and there's less speed over the wings and all the control surfaces I
don't have as much power.
You're going to have to really wait for the control surface to create some sort of force you know as
I get even lower down it's just a lot more sluggish.
All right.
So I just crashed my plane anyway.
That is literally how we go and control the efficiency of our control surfaces perfect.
All right.
Please you let me know if you guys have any questions or suggestions.
That is how I would implement that particular feature just because it's controllable.
And yeah let me know what you guys think.
Thanks so much.