Hello, guys.
This video are going to be very short.
I'm going to show you how to make simple input for your mobile phone.
It's going to be simple touch input.
So what we need to do first is go to player and make these two functions public.
Slide button should be public and jump button should be public.
Now let's save it and go back to Unity.
What are you going to do next?
Is go to in-game UI, click UI button, text.
MASH Pro is going to be jump.
Jump button.
We need to make it bigger.
Much bigger.
Like half of the screen.
And we can align it to the right.
So let's click over here, hold alt and shift, click the right side and then maybe put it a bit lower.
And let's duplicate this.
Name it.
Slide.
Button and align it to the left.
A bit lower.
All right.
Now we can select them both and make them transparent.
And when you make a final build, it should be completely transparent like this.
But for now, as we are testing, I'm going to make it slightly visible.
I want to make sure it's working.
Now let's open them and delete text from the inside.
These two we don't need.
Now, next step would be to create a C-sharp script UI jump button.
But let's make it UI button jump.
First, what we need is to go above and type using you to engine event system.
And next, what we're going to use is an interface.
It's a bit difficult to understand, especially if you're a beginner.
But in general, I'll try to explain what the interface does.
So basically interface allows you to have one function with a different functionality on different game
objects that are independent from each other.
For example, we can use a pointer down handler which allows you to call function when a pointer and
pointer is an input device, for example mouse or touch from your finger.
So when pointer on this game object with this interface function will be called let's click alt, enter
and find implement interface the first one.
And this was the function I was talking about.
So we can call this interface from here or from another object.
It's going to be same function with different functionalities.
So for the button jump, we're going to do game manager instance player John Button.
Now let's go back to Unity and create another script.
C-sharp UI.
But on slide and I'm using name button, slide and button jump.
So they are next to each other in the asset folder.
Otherwise, with the names like John Button and Slide button, slide button would be here and John Button
would be at the top because of the alphabetic order.
Yeah.
So let's go to what was that button slide.
We're going to delete, start an update.
You're going to type here using Unity Engine.
U.N. systems.
And then over here, comma.
Boynton down.
We need to find a pointer down.
Click all to enter implement interface.
And here it's going to be the manager, for instance.
Player.
Slide button.
And we actually can do this.
And then click this icon over here to clean it up.
That's the same for button jump.
By the way, there is no difference to do it this way or that way.
I mean, curly brackets or this one, just this one looks.
I like how it looks.
That's it.
We have these two functions now, as I said, on pointer down will be called when pointer down on the
object with this script.
So we need to find our jump button, drag it here, then we need to find slide button, drag it here.
Let's go and see this.
Now tap to start to buttons appeared and jump is working.
So when Jump is working and Slide is working.
Now let's do a bit of polish on this.
Let's take our info bar and find extra live display.
I want to duplicate this and move it to the left like this.
I want to delete one.
And instead of heart over here, I want to place spread of the slide.
Let's go to graphics player.
Slide.
You can take one of the sprites.
Place it here and we need to rename the object.
Slide icon.
We can make it bigger.
Let's press t and if you hold shift, you can increase the size without messing up the resolution.
So maybe something like this is okay.
And this is, I guess, just approximate size, something that you think looks okay.
Don't sweat it out too much.
Now, let's change this one to slide display.
And I want to open my in-game UI here.
I want to add new image that's going to be slide icon.
So slide icon.
Then let's go to our player script over here and we're going to make this slide call down counter public.
Let's go above, find it, make it public.
But I want to hide it in the inspector.
So public.
Hide, Inspector.
Yeah.
And back in the game UI in the update info function we're going to do slide icon enabled equals to layer.
What was that slide cool down counter less than zero.
If you remember, we use very same statement when we try to do slide it to make sure it's available
right here in the slide button.
And we have here a slide button slide called down counter less than zero.
So basically we making this icon enabled if we can do a slide and now back in unity, we need to assign
the image.
Let's drag it here and now, whenever you try to do slide, if it's not available, picture is not going
to be there.
Slide.
Okay, good.
Let's go to the next video.