1 00:00:00,686 --> 00:00:04,800 We need to do a little bit more to complete this. 2 00:00:05,210 --> 00:00:08,600 Currently, the start_countdown animation plays at the start, 3 00:00:08,601 --> 00:00:13,600 so we want to turn that off and then we're going to add a little bit of code 4 00:00:13,601 --> 00:00:18,000 to ensure that we first play the course_overview like so. 5 00:00:18,186 --> 00:00:21,929 When the animation ends, we move to the start_countdown 6 00:00:22,086 --> 00:00:28,086 so open the Obstacle Course script and at the end of the ready function, 7 00:00:28,087 --> 00:00:31,129 we're going to play an animation and queue another one 8 00:00:31,130 --> 00:00:33,900 so go animation_player.play. 9 00:00:33,920 --> 00:00:36,257 We're going to first play the course_overview 10 00:00:36,258 --> 00:00:39,420 and then we'll go animation_player.queue 11 00:00:39,450 --> 00:00:43,200 and we want to queue the start_countdown animation. 12 00:00:43,201 --> 00:00:46,828 If you now play the game by pressing F6, 13 00:00:46,829 --> 00:00:49,671 you'll see the course_overview animation starts. 14 00:00:50,271 --> 00:00:54,460 We have still a bit of that animation that we need to clear. 15 00:00:54,490 --> 00:00:58,700 I don't know why, but we'll fix that in a second. 16 00:00:58,730 --> 00:01:01,114 You have these two animations queuing up, 17 00:01:01,115 --> 00:01:03,900 but you can't skip ahead right now, right? 18 00:01:03,930 --> 00:01:06,130 If I play and I try to press keys, 19 00:01:06,160 --> 00:01:08,770 you just have that long animation. 20 00:01:08,800 --> 00:01:11,400 Once you've seen it once, you don't want to see it a second time 21 00:01:11,401 --> 00:01:15,210 so you want to let the player skip ahead. 22 00:01:15,240 --> 00:01:16,620 How do you do that? 23 00:01:16,650 --> 00:01:18,290 With a new function. 24 00:01:18,320 --> 00:01:20,203 Below the ready function, 25 00:01:20,204 --> 00:01:24,871 we're going to add a new function named unhandled_input 26 00:01:24,872 --> 00:01:29,770 and that one receives individual key presses from the player, 27 00:01:29,771 --> 00:01:34,290 and other inputs as this event perimeter. 28 00:01:34,320 --> 00:01:36,943 We can use that similarly to the input object, 29 00:01:36,944 --> 00:01:41,842 which we used before, by calling an is_action_pressed function 30 00:01:41,843 --> 00:01:46,786 and others like those on the event, to check if a certain key was pressed. 31 00:01:46,787 --> 00:01:51,552 In this case, we can say, if event.is_action_pressed 32 00:01:51,553 --> 00:01:54,100 and we're going to go with ui. 33 00:01:54,130 --> 00:01:59,091 There's one that's built into every Godot Project that's ui_accept. 34 00:01:59,092 --> 00:02:01,120 If the player presses that, 35 00:02:01,150 --> 00:02:03,780 so that would be the enter key, the space key. 36 00:02:03,810 --> 00:02:09,170 Then we want to skip the course_overview animation, 37 00:02:09,200 --> 00:02:13,773 so what we can do is go animation_player.seek 38 00:02:13,973 --> 00:02:17,286 we seek to INF to the end of the animation 39 00:02:17,287 --> 00:02:20,686 and because we queued the start_countdown animation, 40 00:02:20,687 --> 00:02:23,140 it will automatically play next. 41 00:02:23,170 --> 00:02:25,600 Then we don't want to end any animation 42 00:02:25,601 --> 00:02:29,229 when the player presses this ui_accept action. 43 00:02:29,230 --> 00:02:36,071 One thing we can do is turn off processing for these input events, in this function. 44 00:02:36,072 --> 00:02:40,914 There's a function called set_process_unhandled_input 45 00:02:40,915 --> 00:02:48,471 and you can call it with a value of false to turn off course to unhandled_input. 46 00:02:48,472 --> 00:02:51,657 We've done that similarly for physics_process before 47 00:02:51,658 --> 00:02:55,100 by calling set_physics_process to false. 48 00:02:55,120 --> 00:02:58,700 Now the good thing about this unhandled_input function is that 49 00:02:58,701 --> 00:03:02,557 it receives the key presses individually as perimeters, 50 00:03:02,558 --> 00:03:06,538 and you can use it to precisely run some code 51 00:03:06,539 --> 00:03:11,340 just when some key was pressed, like what we are doing right now. 52 00:03:11,370 --> 00:03:16,700 You'll find a bit more information about why you want to use this, below the video. 53 00:03:17,043 --> 00:03:19,309 With that, you can now play the game. 54 00:03:19,310 --> 00:03:23,600 If you press the space key, you will skip ahead to the countdown animation. 55 00:03:23,601 --> 00:03:29,820 We have one last thing to fix it's that with movement animation, 56 00:03:29,850 --> 00:03:32,940 that we were getting in our overview animation, 57 00:03:32,960 --> 00:03:37,020 so we go back to the animation player to the course_overview animation. 58 00:03:37,050 --> 00:03:40,186 I want to see what's happening with my position there. 59 00:03:40,557 --> 00:03:45,370 I see that somehow the Easings have come back to linear 60 00:03:45,371 --> 00:03:51,456 so I'm going to reselect my keys, right-click, zero 61 00:03:51,457 --> 00:03:58,700 and now ensure to save the animation and now it's jumping instantly again. 62 00:03:59,971 --> 00:04:04,800 Perhaps more safety, one thing that you can do is go to the keyframe 63 00:04:04,801 --> 00:04:08,270 where the jump happens and we're going to duplicate 64 00:04:08,271 --> 00:04:13,229 just the screen being black that way, regardless of what happens, right? 65 00:04:13,230 --> 00:04:16,780 If you have a bug on your phone, get some Easing. 66 00:04:16,800 --> 00:04:19,843 The screen will be completely black at that moment, 67 00:04:19,844 --> 00:04:22,457 covering any weird motion that would happen. 68 00:04:22,458 --> 00:04:24,457 Same thing here, right-click, 69 00:04:24,458 --> 00:04:28,557 I duplicate the key where the screen is black. 70 00:04:28,829 --> 00:04:32,714 That way, I'm sure that the motion of the camera, 71 00:04:32,800 --> 00:04:35,000 if any, will never show. 72 00:04:35,371 --> 00:04:37,780 There's one last thing we can do for polish. 73 00:04:37,800 --> 00:04:40,786 If I run the game and see the animation, 74 00:04:40,787 --> 00:04:44,980 it's currently linear so the camera goes at a constant speed 75 00:04:45,010 --> 00:04:48,686 would be nicer if it would accelerate and decelerate. 76 00:04:48,843 --> 00:04:51,740 I'm going to select my keys, 77 00:04:51,770 --> 00:04:57,900 the first keys of every move animation of the camera 78 00:04:57,920 --> 00:05:02,300 so this one, the one after the jump, and the one after the second jump 79 00:05:02,301 --> 00:05:06,214 and right-click on the Easing field in the Inspector 80 00:05:06,215 --> 00:05:09,420 and select In-Out, save. 81 00:05:09,450 --> 00:05:13,000 With that, if you play, you'll see the camera accelerates a bit, 82 00:05:13,001 --> 00:05:16,940 it slows down, it accelerates, it slows down. 83 00:05:16,970 --> 00:05:18,442 It's not perfect, right? 84 00:05:18,443 --> 00:05:23,540 The fade could be a bit longer but at least it's not the worst. 85 00:05:23,560 --> 00:05:25,829 Perhaps, I think I would move the curve 86 00:05:25,830 --> 00:05:30,580 a little bit to have a little bit less of that Easing. 87 00:05:30,600 --> 00:05:34,660 It accelerates slightly and decelerate slightly. 88 00:05:34,690 --> 00:05:40,186 Yeah, it's much better and it's not too exaggerated like the default preset. 89 00:05:40,400 --> 00:05:45,600 With that, you have a nice overview animation for the start of your game. 90 00:05:45,601 --> 00:05:48,900 You could add a similar one for the end of the game 91 00:05:48,901 --> 00:05:54,200 and just play the animation from the Obstacle Courses finish function. 92 00:05:54,343 --> 00:05:57,400 But for now, that completes this series. 93 00:05:57,571 --> 00:06:01,028 The next series is dedicated to Sights Crawling Game 94 00:06:01,029 --> 00:06:03,400 because the code can be a little bit different. 95 00:06:03,401 --> 00:06:07,660 Johnny will be your host for the videos in that series. 96 00:06:07,690 --> 00:06:11,557 I hope that you'll enjoy it and I'll see you after that. 97 00:06:11,643 --> 00:06:12,543 See you later.