1 00:00:00,000 --> 00:00:03,100 In this video, we'll create the base pickup scene. 2 00:00:03,101 --> 00:00:08,029 We'll then inherit it to create the ghost pickup and the speed pickup. 3 00:00:08,030 --> 00:00:10,529 We're creating an inherited scene 4 00:00:10,530 --> 00:00:13,786 because we're going to have some animations running 5 00:00:13,787 --> 00:00:17,500 that we want to reuse across all pickups. 6 00:00:17,501 --> 00:00:21,057 Similarly, we'll extend a base script for the code 7 00:00:21,058 --> 00:00:23,814 so that we can share functionality. 8 00:00:24,343 --> 00:00:28,486 For now, we're going to set up the scene and create the animations. 9 00:00:28,487 --> 00:00:31,557 We're not going to make the particles just yet. 10 00:00:31,558 --> 00:00:34,257 We'll do that around the end of the series. 11 00:00:34,258 --> 00:00:36,300 With that said, let's get started. 12 00:00:36,447 --> 00:00:39,643 Let's get started by creating the pickup scene. 13 00:00:39,644 --> 00:00:43,913 We'll be working in the ObstacleCourse and this called Part2 folder 14 00:00:43,914 --> 00:00:46,486 that you'll find in the Godot Practices project. 15 00:00:46,487 --> 00:00:50,071 This is just so that we all start on the same page. 16 00:00:50,471 --> 00:00:51,540 Expand the folder. 17 00:00:51,541 --> 00:00:55,186 We're going to right click on it and create a new folder 18 00:00:55,187 --> 00:00:57,314 where we'll store our pickups. 19 00:00:57,315 --> 00:00:59,129 Let's call it pickups. 20 00:01:00,129 --> 00:01:03,200 In that folder, the pickups folder, we right click, 21 00:01:03,259 --> 00:01:07,057 and we're going to create a new scene for the pickup. 22 00:01:07,214 --> 00:01:09,285 Which we'll name this way. 23 00:01:09,485 --> 00:01:12,314 This is going to be the same pattern as before. 24 00:01:12,315 --> 00:01:13,557 This is a collectible, 25 00:01:13,558 --> 00:01:18,100 so we need an area to detect when the character touches the pickup. 26 00:01:18,101 --> 00:01:20,957 We start with an Area2D node. 27 00:01:22,429 --> 00:01:26,060 An Area2D needs a collision shape. 28 00:01:26,386 --> 00:01:29,867 Next, we add a CollisionShape2D node. 29 00:01:30,357 --> 00:01:36,029 In the Inspector, we're going to set the shape to a new CircleShape2D. 30 00:01:37,029 --> 00:01:40,600 Then we're going to drag our sprites in there. 31 00:01:41,100 --> 00:01:45,857 We have an assets subfolder in the ObstacleCourse_Part2 folder. 32 00:01:46,071 --> 00:01:51,900 Expand it, and we're going to look for the pickup gem and the shadow circle. 33 00:01:51,901 --> 00:01:55,386 Drag and drop them onto the view like so. 34 00:01:55,929 --> 00:01:56,786 We want to make sure 35 00:01:56,787 --> 00:02:01,229 that the shadow circle is behind the pickup gem. 36 00:02:01,230 --> 00:02:05,000 We move it up in the Inspector. 37 00:02:05,186 --> 00:02:06,800 Then we're going to take the gem 38 00:02:06,801 --> 00:02:12,800 and we're going to move it up a little bit above the circle. 39 00:02:12,801 --> 00:02:17,086 I'm also going to center it on the vertical axis 40 00:02:17,087 --> 00:02:22,171 so that it's placed symmetrically along that axis. 41 00:02:22,943 --> 00:02:28,229 Finally, we are going to lower the scale of that shadow circle a bit. 42 00:02:28,543 --> 00:02:33,071 To scale the shadow circle, click it to select it in the view. 43 00:02:33,072 --> 00:02:36,857 And then you're going to press Alt, click and drag. 44 00:02:37,100 --> 00:02:41,370 If you want the scale to be uniform, you're going to have the Shift key 45 00:02:41,371 --> 00:02:43,700 pressed as well as you do this. 46 00:02:44,290 --> 00:02:47,957 Same thing, I'm going to nudge it with the arrow keys 47 00:02:47,958 --> 00:02:50,871 to align it onto the vertical axis. 48 00:02:50,872 --> 00:02:54,713 The next thing we want to do is to make that semitransparent. 49 00:02:54,714 --> 00:02:56,543 Do you remember how we do that? 50 00:02:56,544 --> 00:02:59,771 With the shadow circle selected, we go to the Inspector, 51 00:02:59,772 --> 00:03:02,529 the Visibility category, Modulate. 52 00:03:02,686 --> 00:03:06,171 And we're going to lower the Alpha channel a bit. 53 00:03:06,943 --> 00:03:11,314 This will look better when overlaid on top of the final level. 54 00:03:11,443 --> 00:03:14,071 The last thing we have to do is resize the collision shape 55 00:03:14,072 --> 00:03:16,343 because it doesn't match the pickup. 56 00:03:16,414 --> 00:03:19,243 Now, if you try to click to select it in the view, 57 00:03:19,244 --> 00:03:23,942 because the sprite is in front of it, you're not going to be able to do that. 58 00:03:23,943 --> 00:03:25,386 Well, here's the trick. 59 00:03:25,387 --> 00:03:28,971 You can press the Alt key down, and right click 60 00:03:28,972 --> 00:03:33,343 to bring a drop down menu letting you select a node 61 00:03:33,829 --> 00:03:36,014 that is stacked in the view. 62 00:03:36,229 --> 00:03:40,571 You can Alt, right click over the sprite and the collision shape. 63 00:03:40,572 --> 00:03:43,671 And then you can select the collision shape from the menu. 64 00:03:43,672 --> 00:03:45,629 This is a very handy feature. 65 00:03:45,743 --> 00:03:49,914 When you've done that to move the shape, 66 00:03:49,915 --> 00:03:53,214 you're going to press the W key to bring the move tool. 67 00:03:53,215 --> 00:03:55,757 Then Shift, click and drag. 68 00:03:56,074 --> 00:04:01,921 Actually, we're going to put it in front of the sprites in the scene dock. 69 00:04:01,922 --> 00:04:04,857 Because otherwise, it's a bit difficult to see. 70 00:04:05,314 --> 00:04:09,256 We're going to click and drag on the resize handle 71 00:04:09,257 --> 00:04:12,443 with the select tool active in the toolbar 72 00:04:12,444 --> 00:04:16,600 to make the pickup about as big as the sprite. 73 00:04:17,450 --> 00:04:21,079 The last node we'll add is the animation player here. 74 00:04:21,080 --> 00:04:26,893 Select the Area2D, press CTRL+A, and add an animation player node. 75 00:04:28,143 --> 00:04:31,300 We'll just create the animation by going to the Animation menu, 76 00:04:31,301 --> 00:04:35,471 we click and select New, and we'll call this one idle. 77 00:04:35,472 --> 00:04:38,057 This will be the gem moving up and down. 78 00:04:38,486 --> 00:04:41,429 With that, we can get started animating the gem.