We need to do a little bit more to complete this.
Currently, the start_countdown animation plays at the start,
so we want to turn that off and then we're going to add a little bit of code
to ensure that we first play the course_overview like so.
When the animation ends, we move to the start_countdown
so open the Obstacle Course script and at the end of the ready function,
we're going to play an animation and queue another one
so go animation_player.play.
We're going to first play the course_overview
and then we'll go animation_player.queue
and we want to queue the start_countdown animation.
If you now play the game by pressing F6,
you'll see the course_overview animation starts.
We have still a bit of that animation that we need to clear.
I don't know why, but we'll fix that in a second.
You have these two animations queuing up,
but you can't skip ahead right now, right?
If I play and I try to press keys,
you just have that long animation.
Once you've seen it once, you don't want to see it a second time
so you want to let the player skip ahead.
How do you do that?
With a new function.
Below the ready function,
we're going to add a new function named unhandled_input
and that one receives individual key presses from the player,
and other inputs as this event perimeter.
We can use that similarly to the input object,
which we used before, by calling an is_action_pressed function
and others like those on the event, to check if a certain key was pressed.
In this case, we can say, if event.is_action_pressed
and we're going to go with ui.
There's one that's built into every Godot Project that's ui_accept.
If the player presses that,
so that would be the enter key, the space key.
Then we want to skip the course_overview animation,
so what we can do is go animation_player.seek
we seek to INF to the end of the animation
and because we queued the start_countdown animation,
it will automatically play next.
Then we don't want to end any animation
when the player presses this ui_accept action.
One thing we can do is turn off processing for these input events, in this function.
There's a function called set_process_unhandled_input
and you can call it with a value of false to turn off course to unhandled_input.
We've done that similarly for physics_process before
by calling set_physics_process to false.
Now the good thing about this unhandled_input function is that
it receives the key presses individually as perimeters,
and you can use it to precisely run some code
just when some key was pressed, like what we are doing right now.
You'll find a bit more information about why you want to use this, below the video.
With that, you can now play the game.
If you press the space key, you will skip ahead to the countdown animation.
We have one last thing to fix it's that with movement animation,
that we were getting in our overview animation,
so we go back to the animation player to the course_overview animation.
I want to see what's happening with my position there.
I see that somehow the Easings have come back to linear
so I'm going to reselect my keys, right-click, zero
and now ensure to save the animation and now it's jumping instantly again.
Perhaps more safety, one thing that you can do is go to the keyframe
where the jump happens and we're going to duplicate
just the screen being black that way, regardless of what happens, right?
If you have a bug on your phone, get some Easing.
The screen will be completely black at that moment,
covering any weird motion that would happen.
Same thing here, right-click,
I duplicate the key where the screen is black.
That way, I'm sure that the motion of the camera,
if any, will never show.
There's one last thing we can do for polish.
If I run the game and see the animation,
it's currently linear so the camera goes at a constant speed
would be nicer if it would accelerate and decelerate.
I'm going to select my keys,
the first keys of every move animation of the camera
so this one, the one after the jump, and the one after the second jump
and right-click on the Easing field in the Inspector
and select In-Out, save.
With that, if you play, you'll see the camera accelerates a bit,
it slows down, it accelerates, it slows down.
It's not perfect, right?
The fade could be a bit longer but at least it's not the worst.
Perhaps, I think I would move the curve
a little bit to have a little bit less of that Easing.
It accelerates slightly and decelerate slightly.
Yeah, it's much better and it's not too exaggerated like the default preset.
With that, you have a nice overview animation for the start of your game.
You could add a similar one for the end of the game
and just play the animation from the Obstacle Courses finish function.
But for now, that completes this series.
The next series is dedicated to Sights Crawling Game
because the code can be a little bit different.
Johnny will be your host for the videos in that series.
I hope that you'll enjoy it and I'll see you after that.
See you later.