﻿1
00:00:04,420 --> 00:00:05,890
‫Hey, welcome back.

2
00:00:05,920 --> 00:00:10,720
‫In the last video, we created our capsule component, and we set it to be the root.

3
00:00:10,750 --> 00:00:13,960
‫In this video, we need to add some more components.

4
00:00:13,960 --> 00:00:18,520
‫Specifically, we need some meshes for the base and the turret part of our tank.

5
00:00:19,030 --> 00:00:24,100
‫And we also need a projectile spawn point, as we've discussed in previous lectures.

6
00:00:24,280 --> 00:00:26,230
‫So let's hop into VS code.

7
00:00:26,260 --> 00:00:29,950
‫Now here in Base Pancake, we have our capsule component.

8
00:00:29,950 --> 00:00:34,540
‫We can add our other components in this private section just below it.

9
00:00:34,570 --> 00:00:39,370
‫So for our meshes we want to use you static mesh component.

10
00:00:39,610 --> 00:00:45,580
‫And of course these will be pointers as this isn't a base type and the first mesh I'm going to call

11
00:00:45,580 --> 00:00:51,790
‫base mesh and just like capsule comp base mesh will get its own you property macro.

12
00:00:51,940 --> 00:00:57,760
‫Now notice you static mesh component is not giving me an error for not forward declaring it.

13
00:00:57,760 --> 00:01:03,820
‫That's because you static mesh component is included by default in all actors and of course pawns are

14
00:01:03,820 --> 00:01:07,090
‫actors, so it has used static mesh component.

15
00:01:07,120 --> 00:01:11,860
‫Now if you're wondering how to know which types are included by default and which are not, you can

16
00:01:11,860 --> 00:01:14,230
‫always try to compile and see if you get an error.

17
00:01:14,230 --> 00:01:18,820
‫We know what the error looks like when you fail to include a header that you need.

18
00:01:18,850 --> 00:01:25,000
‫Another approach would be to always forward declare and always include header files for unreal engine

19
00:01:25,000 --> 00:01:30,490
‫types have include guards that prevent them from being included multiple times in a single file.

20
00:01:30,520 --> 00:01:33,700
‫In fact, the very header we're in has one of these.

21
00:01:33,700 --> 00:01:35,620
‫It's called Prague WMA once.

22
00:01:35,620 --> 00:01:40,180
‫So anyway, we have our base mesh and we'd like another static mesh component.

23
00:01:40,180 --> 00:01:46,300
‫So this will be a U static mesh component pointer and this will be for the turret.

24
00:01:46,300 --> 00:01:52,660
‫So I'm going to call this turret mesh and just like base mesh, it will also get a U property macro.

25
00:01:52,660 --> 00:01:58,030
‫So now that we have our base mesh and turret mesh pointers, it's time to actually construct these.

26
00:01:58,030 --> 00:02:02,980
‫So let's head over to Base Pont CP and do that in the constructor here.

27
00:02:02,980 --> 00:02:09,670
‫So first we're going to say base mesh and we'll assign this the value returned by create default sub

28
00:02:09,670 --> 00:02:10,420
‫object.

29
00:02:10,420 --> 00:02:15,370
‫Now before I fill it in, why don't you go ahead and type in the correct type here?

30
00:02:17,280 --> 00:02:17,910
‫That's right.

31
00:02:17,910 --> 00:02:20,450
‫It's you static mesh component.

32
00:02:20,460 --> 00:02:26,190
‫Now for the name, we're going to use the text macro and we can call this base mesh.

33
00:02:26,400 --> 00:02:32,010
‫Now it's important that we attach base mesh to something, since we'd like the mesh to follow the capsule

34
00:02:32,010 --> 00:02:32,880
‫component around.

35
00:02:32,880 --> 00:02:36,300
‫As we're moving the PON, we're going to attach it to the root.

36
00:02:36,420 --> 00:02:45,450
‫So base mesh has a function called setup attachment and setup attachment takes a seen component to attach

37
00:02:45,450 --> 00:02:46,050
‫to.

38
00:02:46,080 --> 00:02:49,320
‫We're going to attach base mesh to capsule comp.

39
00:02:49,380 --> 00:02:52,560
‫We could easily have past root component in here.

40
00:02:52,860 --> 00:02:56,220
‫Now we're going to create the turret mesh in the same way.

41
00:02:56,220 --> 00:03:04,620
‫So turret mesh equals create default sub object and this will also be a use static mesh component.

42
00:03:04,950 --> 00:03:08,550
‫And for the name for this one, we'll call this turret mesh.

43
00:03:09,840 --> 00:03:14,940
‫Now we mentioned previously that we'd like the turret mesh to be attached to base mesh so we can say

44
00:03:14,970 --> 00:03:21,480
‫turret mesh set up attachment and the component will attach it to will be base mesh.

45
00:03:21,810 --> 00:03:27,600
‫So we'll pass base mesh and as the argument so where does setup attachment come from?

46
00:03:27,600 --> 00:03:33,420
‫If we right click and go to definition, we'll see that it's a function here in scene component.

47
00:03:33,570 --> 00:03:36,180
‫So all scene components have this function.

48
00:03:36,420 --> 00:03:38,400
‫So we'll close out of scene component.

49
00:03:38,820 --> 00:03:43,800
‫Now you're probably noticing the IntelliSense errors saying pointer to incomplete class type.

50
00:03:43,800 --> 00:03:46,050
‫This is actually another false error.

51
00:03:46,050 --> 00:03:51,870
‫And that extension we downloaded doesn't actually fix this, but this compiles just fine, so we don't

52
00:03:51,870 --> 00:03:53,040
‫need to worry about it.

53
00:03:53,040 --> 00:04:03,000
‫Now, if it's bothering you, you could just add the include include components slash static mesh component

54
00:04:04,170 --> 00:04:06,600
‫and that'll get rid of those red squiggles.

55
00:04:06,600 --> 00:04:11,220
‫And as I mentioned, these have include guards so they won't be included twice.

56
00:04:11,220 --> 00:04:12,540
‫So that's up to you.

57
00:04:12,570 --> 00:04:16,410
‫I'll go ahead and leave the include here just so we don't get those squiggles.

58
00:04:16,410 --> 00:04:22,620
‫So now that we have our base mesh in our turret mesh, the only thing left is our projectile spawn point.

59
00:04:22,620 --> 00:04:24,770
‫So this will be your challenge.

60
00:04:25,050 --> 00:04:28,860
‫Create a pointer called projectile spawn point.

61
00:04:29,190 --> 00:04:35,070
‫Choose the correct type that's appropriate for a projectile spawn point and give it a name using the

62
00:04:35,070 --> 00:04:38,460
‫text macro and create default sub object.

63
00:04:38,610 --> 00:04:42,090
‫Attach the projectile spawn point to the turret mesh.

64
00:04:42,270 --> 00:04:47,730
‫And a question I want you to think about is do we need to include its header file, pause the video

65
00:04:47,850 --> 00:04:49,860
‫and create this component now?

66
00:04:52,650 --> 00:04:53,280
‫All right.

67
00:04:53,280 --> 00:04:55,360
‫So let's add this next component.

68
00:04:55,380 --> 00:05:03,170
‫Now, the projectile spawn point will be a U seen component, and we'll call this projectile spawn point.

69
00:05:03,180 --> 00:05:05,550
‫Now we'll add a you property macro.

70
00:05:05,580 --> 00:05:06,180
‫That's okay.

71
00:05:06,180 --> 00:05:11,790
‫If you didn't do this, if you didn't just go ahead and add the you property macro now, now let's go

72
00:05:11,790 --> 00:05:15,300
‫to Base Pond CP and construct this component.

73
00:05:15,300 --> 00:05:22,290
‫So we're going to say projectile spawn point and create default sub object.

74
00:05:22,290 --> 00:05:25,320
‫And this will be a you seen component.

75
00:05:25,350 --> 00:05:28,080
‫Now, you probably gave this an awesome name.

76
00:05:28,080 --> 00:05:32,910
‫I'm just going to call it Spawn point and we need to set up the attachment for this.

77
00:05:32,910 --> 00:05:41,190
‫So we're going to say projectile spawn point, set up attachment and will attach this to turret mesh

78
00:05:41,400 --> 00:05:48,840
‫and there we go so we can compile this, make sure everything compiles successfully and we have a successful

79
00:05:48,840 --> 00:05:49,620
‫compile.

80
00:05:49,620 --> 00:05:51,570
‫So everything's looking great.

81
00:05:51,570 --> 00:05:57,540
‫So in this video we created static mesh components and we saw that we didn't need to include the headers

82
00:05:57,540 --> 00:05:58,320
‫for those.

83
00:05:58,320 --> 00:06:00,330
‫They were already included by default.

84
00:06:00,330 --> 00:06:07,140
‫We also created a scene component called projectile spawn point and our code compiled just fine without

85
00:06:07,140 --> 00:06:09,240
‫including the header for that as well.

86
00:06:09,270 --> 00:06:13,920
‫We'll be creating a blueprint based on our base pond C++ class very soon.

87
00:06:14,070 --> 00:06:15,480
‫I'll see you in the next video.

