OK so now that we have the core of our controls all hooked up so let's go and concentrate on creating
the break button for our airplane.
So let's jump over into unity and get hooked up.
OK so the first thing that we need to do to get our break button all hooked up is come into the control
panel for the mobile canvas here.
And what I want to do is I want to create a new button.
So we're going to create a new button right there I'm going to call this the break button.
All right.
And what I want to do is if you go into the mobile textures whole folder here for UI you can see I added
a new button called the Mobile break button.
So what I'm going to do is add that to the source image and then just hit the preserve aspect and then
set native size that's going to make it really big.
And I'm just going to scale it down a little bit.
We want it to be relatively large so that way it's you know pretty easy for the player to hit on a mobile
device.
All right.
So the other thing we don't really need is the text.
I just make it into the texture.
Now obviously you're more than welcome to go and make your own textures for these.
I'm just kind of getting things set up here so I'm going to put the brake button up here.
I think that's a good spot for it.
And what I want to do is give it a little bit of color so I make a kind of reddish something like that
you know it's like a emergency brake type of color.
There we go.
OK.
So with that all hooked up all we need to do is add a really tiny function to our code so I'm going
to jump back into Visual Studio and you'll see why here in a second.
But what I want to do is I want to create a new public void method called a handle brake.
All right.
Or we could actually say set break.
How about that.
I think that's going to be a little bit more descriptive or it will break to a value.
So the first argument is going to be a value.
All right and that's just because we're going to be passing in an exact value for what the brakes should
be set.
OK so what I'm going to do is type outbreak which is already a one of those methods or variables that
comes with the base airplane inputs and I'm literally just going to set it to a value because what we
can do now is we can actually come over here into unity and we could set up an event trigger on this
button right here and this event trigger basically will send out an event you know and it will set that
particular brake value.
So what I want to do is I want to come in here to this add component with the brake button selected.
And when it come in here and say add an event trigger so you can start typing it out a pair of trigger.
That's what we want and what we're looking for is the pointer up and pointer down methods or events.
I should say.
All right so these are just like that on click event.
These are listeners or events that you can actually listen for.
You can also do this in code but you know I find it nice and quick to set this up manually like this
a little more visual too.
So what I did is I added two new listeners so one for the pointer up and one for the pointer down and
all I need to do now is drag and drop the indie pixel airplane into this.
All right.
And then from these function dropdown what I want to do is select the mobile airplane input then select
the set break method and when we pull up or we pull our finger off the button we want to set the brake
dizzier and when we put our finger down on the button we want to set our brakes do one simple as that.
All right.
So it's not very common at all.
So let's go and test it out now.
Inside the editor I hear something I play.
All right so I'm going to throttle up just to get us moving throttle back down all the way and hold
down the brake and it's working perfect.
OK.
So there's the brake button.
So the next couple of lectures what we're going to do is focus on getting the flaps buttons all of them.
OK.
Thanks so much.