WEBVTT 1 00:00:05.900 --> 00:00:09.900 Utilizing montages and handling shooting direction 2 00:00:23.340 --> 00:00:25.740 Hello, my name is Young hoon Lee 3 00:00:25.740 --> 00:00:28.850 In this lesson, we will learn about how to utilize montages 4 00:00:28.850 --> 00:00:32.830 And we will learn about how to create shooting effect 5 00:00:32.830 --> 00:00:37.090 In this chapter, we will learn how to create animation motages 6 00:00:37.090 --> 00:00:39.290 And how to play them 7 00:00:39.290 --> 00:00:42.750 In animation blueprints 8 00:00:42.750 --> 00:00:45.700 Additionally, we will learn 9 00:00:45.700 --> 00:00:48.659 How to attach grenade launchers and sniper rifles 10 00:00:48.659 --> 00:00:51.259 To the hands 11 00:00:51.259 --> 00:00:54.200 And how to handle camera motion during shooting 12 00:00:54.817 --> 00:00:58.567 Animation Montage Creation 13 00:00:59.720 --> 00:01:03.080 Let's implement an animation of shooting gun 14 00:01:03.080 --> 00:01:06.599 Where the main character fires a weapon 15 00:01:06.599 --> 00:01:09.800 If you take a look at this animations folder 16 00:01:09.800 --> 00:01:12.800 And search for fire 17 00:01:12.800 --> 00:01:18.000 You will be able to find an animation called Fire Rifle Ironsights 18 00:01:18.000 --> 00:01:19.760 We will implement this animation 19 00:01:19.760 --> 00:01:23.279 This animation include character's shoulder movement 20 00:01:23.279 --> 00:01:27.559 Now, we will control this animation 21 00:01:27.559 --> 00:01:30.480 By inserting it into the animation blueprint like this 22 00:01:30.480 --> 00:01:35.599 It seems a bit challenging to insert it into the existing state machine 23 00:01:35.599 --> 00:01:37.040 Of course, you can do it here 24 00:01:37.040 --> 00:01:39.440 Like this, add the state 25 00:01:39.440 --> 00:01:42.720 You can add shoulder movement, state of attacking 26 00:01:42.720 --> 00:01:46.160 Instead of doing it that way 27 00:01:46.160 --> 00:01:48.199 It's better for the animation to return to the original state after activating 28 00:01:48.199 --> 00:01:51.480 So, we will control the animation to have that effect 29 00:01:51.480 --> 00:01:54.279 There is a feature that gathers animations into one place 30 00:01:54.279 --> 00:01:56.559 It collects animation sequences 31 00:01:56.559 --> 00:02:00.160 Making into one allowing us to control them more easily 32 00:02:00.160 --> 00:02:03.720 In Unreal Engine, we call it an Animation Montage 33 00:02:03.720 --> 00:02:07.000 Let's take a look at the definition of montage 34 00:02:07.000 --> 00:02:08.240 This is what it means 35 00:02:08.240 --> 00:02:11.720 Often used in movies and films 36 00:02:11.720 --> 00:02:15.279 Combining multiple scenes together 37 00:02:15.279 --> 00:02:20.880 So, montage is the concept of combining 38 00:02:20.880 --> 00:02:23.919 Multiple elements into a single animation 39 00:02:23.919 --> 00:02:27.639 Now, Let's create a montage and control it 40 00:02:27.639 --> 00:02:29.880 Let's name the montage as Fire 41 00:02:29.880 --> 00:02:34.919 In the Blueprint folder, right click and create an Animation Montage 42 00:02:34.919 --> 00:02:39.479 By selecting Create Animation Montage, from the context menu 43 00:02:39.479 --> 00:02:42.520 Now, you'll need to select the skeleton 44 00:02:42.520 --> 00:02:44.550 We are using this now 45 00:02:44.550 --> 00:02:46.370 Set it up like this 46 00:02:46.370 --> 00:02:50.919 Since it's a montage 47 00:02:50.919 --> 00:02:56.589 I'll rename it as Montage Fire 48 00:02:57.839 --> 00:03:00.279 Now, let's open it 49 00:03:00.279 --> 00:03:01.919 This is how it will look like 50 00:03:01.919 --> 00:03:04.080 A montage is structured like this 51 00:03:04.080 --> 00:03:06.160 There is montage 52 00:03:06.160 --> 00:03:08.759 And then, at the top 53 00:03:08.759 --> 00:03:10.399 This part is called sections 54 00:03:10.399 --> 00:03:13.639 If you right click here 55 00:03:13.639 --> 00:03:15.759 It's name appears, sections 56 00:03:15.759 --> 00:03:17.360 The very top one is called sections 57 00:03:17.360 --> 00:03:19.759 The second one is called a slot 58 00:03:19.759 --> 00:03:23.559 Basically, montages are linked together through slots like this 59 00:03:23.559 --> 00:03:25.240 Montage is a slot 60 00:03:25.240 --> 00:03:27.160 That's how you should remember it 61 00:03:27.160 --> 00:03:29.199 We can add slots 62 00:03:29.199 --> 00:03:30.199 These slot names you see here are 63 00:03:30.199 --> 00:03:33.479 Just basic default setting 64 00:03:33.479 --> 00:03:36.240 You can add new slots 65 00:03:36.240 --> 00:03:37.360 And when you do that 66 00:03:37.360 --> 00:03:38.679 There is something called slot manager 67 00:03:38.679 --> 00:03:39.759 If you click it 68 00:03:39.759 --> 00:03:43.520 you can add slots right here 69 00:03:43.520 --> 00:03:46.730 This menu is over here as well 70 00:03:46.730 --> 00:03:47.960 If you look at the top over here 71 00:03:47.960 --> 00:03:52.520 Should be in the window catergory 72 00:03:52.520 --> 00:03:55.000 You can see Anim Slot Manger in the window category 73 00:03:55.000 --> 00:03:56.320 This has the same features 74 00:03:56.320 --> 00:04:00.119 Clicking this also adds a tab 75 00:04:00.119 --> 00:04:03.919 So that was about how you can create a new slot 76 00:04:03.919 --> 00:04:07.320 You'll see notifications and whatnot 77 00:04:07.320 --> 00:04:10.839 Now, let's insert an animation here 78 00:04:10.839 --> 00:04:14.440 I will bring Fire animation 79 00:04:14.440 --> 00:04:17.509 From this asset browser 80 00:04:18.559 --> 00:04:20.839 Because that's what I told you we were going to do 81 00:04:23.839 --> 00:04:26.160 Okay, this is it 82 00:04:26.160 --> 00:04:28.720 Drag it over here 83 00:04:28.720 --> 00:04:35.119 Then now, you have composed a single animation sequence 84 00:04:35.119 --> 00:04:36.880 Of course, you can add more into it 85 00:04:36.880 --> 00:04:38.279 Like so, you can add more 86 00:04:38.279 --> 00:04:40.679 So then, two, three mixed together 87 00:04:40.679 --> 00:04:42.950 And when you play this 88 00:04:42.950 --> 00:04:46.000 You can see multiple animation 89 00:04:46.000 --> 00:04:48.119 Forming one single sequence 90 00:04:48.119 --> 00:04:50.880 This is what we call an animation montage 91 00:04:50.880 --> 00:04:55.399 Alright, for now in the part where the player controls shooting 92 00:04:55.399 --> 00:04:58.499 Let's try controlling it 93 00:04:58.499 --> 00:05:00.559 With just one animation sequence inserted 94 00:05:00.559 --> 00:05:02.079 Like this 95 00:05:02.079 --> 00:05:06.079 Here on the left side, you can see there's a concept called Blends 96 00:05:06.079 --> 00:05:10.529 Blends are the concept where they provide smooth transitions 97 00:05:10.529 --> 00:05:13.119 Between existing animations 98 00:05:13.119 --> 00:05:16.679 And a new animation during the transition 99 00:05:16.679 --> 00:05:20.840 For example, you can think of it in this way 100 00:05:21.490 --> 00:05:26.279 If the animation ends like this 101 00:05:26.279 --> 00:05:33.920 But the shooting animation is set up like this 102 00:05:33.920 --> 00:05:37.399 Then the arm movement wouldn't be smooth 103 00:05:37.399 --> 00:05:40.299 Transitioning directly like this 104 00:05:40.299 --> 00:05:43.040 Would feel very awkward and abrupt 105 00:05:43.040 --> 00:05:46.320 But if you use blends, it will be like this 106 00:05:46.320 --> 00:05:49.559 Additional frames are automatically generated 107 00:05:49.559 --> 00:05:53.959 So, the arm gradually stiffens like this 108 00:05:53.959 --> 00:05:57.559 Gradually lifts up 109 00:05:57.559 --> 00:05:59.160 I'm not good at drawing, but anyway 110 00:05:59.160 --> 00:06:01.839 I want to say that it's done in a way that gives this kind of feeling 111 00:06:01.839 --> 00:06:04.440 Like this, and then it transitions into this 112 00:06:04.440 --> 00:06:08.000 It would be nice if it could be drawn more beautifully like this 113 00:06:08.000 --> 00:06:10.959 This is how you create intermediate frames like this 114 00:06:10.959 --> 00:06:14.170 This is what we call blending 115 00:06:14.170 --> 00:06:16.320 There are various terms 116 00:06:16.320 --> 00:06:19.959 The term blend is used 117 00:06:19.959 --> 00:06:22.839 And sometimes terms like cross 118 00:06:22.839 --> 00:06:24.189 Or crossfade are also used 119 00:06:24.189 --> 00:06:25.440 People also use terms like fade 120 00:06:25.440 --> 00:06:27.600 And terms like blend 121 00:06:27.600 --> 00:06:29.700 In Unreal Engine 122 00:06:29.700 --> 00:06:31.600 We use the term blend 123 00:06:31.600 --> 00:06:34.440 So, there's certain time for blending 124 00:06:34.440 --> 00:06:37.239 If you hold down a keyboard control key 125 00:06:37.239 --> 00:06:41.399 And then scroll the mouse wheel, you can reduce it like this 126 00:06:41.399 --> 00:06:43.839 Alright, let's continue like this No, that's not it 127 00:06:43.839 --> 00:06:47.480 Timeline bar at the top here 128 00:06:47.480 --> 00:06:50.079 If you drag it like this 129 00:06:50.079 --> 00:06:52.440 The total time is 0.23 seconds 130 00:06:52.440 --> 00:06:54.920 If the blend time is 0.25 seconds 131 00:06:54.920 --> 00:06:57.959 The animation wouldn't work 132 00:06:57.959 --> 00:06:59.959 It will not even move 133 00:06:59.959 --> 00:07:02.760 If blending is done while moving 134 00:07:02.760 --> 00:07:05.440 The movement will not be made 135 00:07:05.440 --> 00:07:07.679 Therefore, we need to reduce the time 136 00:07:07.679 --> 00:07:11.320 Will reduce a lot to 0.05 seconds 137 00:07:11.320 --> 00:07:16.290 I'll reduce this to 0.05 seconds to use it effectively 138 00:07:17.440 --> 00:07:21.000 Let's set it up like this for now 139 00:07:22.400 --> 00:07:25.600 And let's save it 140 00:07:25.600 --> 00:07:30.399 Then I'd like to integrate this 141 00:07:30.399 --> 00:07:32.559 Into the animation blueprint 142 00:07:32.559 --> 00:07:36.920 Since we haven't created a separate state here 143 00:07:36.920 --> 00:07:39.160 What you want is to smoothly transition 144 00:07:39.160 --> 00:07:41.559 From the current animation 145 00:07:41.559 --> 00:07:44.440 To briefly play the shooting animation when you shoot 146 00:07:44.440 --> 00:07:47.160 And then return to the original animation 147 00:07:47.160 --> 00:07:50.160 We can do that by inserting animation 148 00:07:50.160 --> 00:07:52.040 In the middle of the action 149 00:07:52.040 --> 00:07:53.679 Let's try 150 00:07:53.679 --> 00:07:57.640 If you left click here 151 00:07:57.640 --> 00:08:01.000 And search default slot, this comes up 152 00:08:01.000 --> 00:08:03.519 You can add slots like this 153 00:08:03.519 --> 00:08:07.279 Like this, connect the slot 154 00:08:07.279 --> 00:08:09.920 For now, create a node 155 00:08:09.920 --> 00:08:12.160 named Default Slot and insert it 156 00:08:12.160 --> 00:08:15.320 Then select this slot 157 00:08:15.320 --> 00:08:19.200 And on the right side, you can see the option to rename the slot 158 00:08:19.200 --> 00:08:21.079 You can change it like this 159 00:08:21.079 --> 00:08:23.239 The existing names 160 00:08:23.239 --> 00:08:26.720 May not be suitable for what I'm trying to do 161 00:08:26.720 --> 00:08:29.570 So, I'll add a new slot 162 00:08:29.570 --> 00:08:32.119 And write it here 163 00:08:32.119 --> 00:08:35.799 Then you go to the Slot Manager here 164 00:08:35.799 --> 00:08:37.679 And click Add Slot 165 00:08:37.679 --> 00:08:39.599 I will name it fire 166 00:08:39.599 --> 00:08:41.780 Click add slot and create and name it FireSlot 167 00:08:43.080 --> 00:08:46.440 Name it like this 168 00:08:46.440 --> 00:08:49.080 You can delete all the default slots 169 00:08:49.080 --> 00:08:50.960 You can insert in the middle like this 170 00:08:50.960 --> 00:08:52.880 Or create a new group 171 00:08:52.880 --> 00:08:56.400 For now, I'll just add a slot 172 00:08:56.400 --> 00:08:57.679 To the default 173 00:08:57.679 --> 00:09:00.159 Well, just adding it like this isn't enough 174 00:09:00.159 --> 00:09:03.239 This is labeled as Default Slot right now 175 00:09:03.239 --> 00:09:05.280 We should rename it 176 00:09:05.280 --> 00:09:09.840 Let's rename it as FireSlot 177 00:09:09.840 --> 00:09:13.640 If the animation isn't reflecting properly for a moment 178 00:09:13.640 --> 00:09:16.200 Try detaching it briefly and then reattaching it 179 00:09:16.200 --> 00:09:19.159 This should make it reflect correctly 180 00:09:19.159 --> 00:09:20.840 It works right? 181 00:09:20.840 --> 00:09:23.960 This is it 182 00:09:23.960 --> 00:09:24.960 If it doesn't work for you 183 00:09:24.960 --> 00:09:26.440 Then, save everything 184 00:09:26.440 --> 00:09:28.679 Try closing it and opening it again 185 00:09:28.679 --> 00:09:31.599 After adding and renaming 186 00:09:31.599 --> 00:09:34.119 Switch back to the Animation Blueprint 187 00:09:34.119 --> 00:09:36.080 Then proceed to rename the slot 188 00:09:36.080 --> 00:09:40.950 Select it like this and replace it with FireSlot 189 00:09:42.000 --> 00:09:43.359 Compile them 190 00:09:43.359 --> 00:09:45.000 What happens is 191 00:09:45.000 --> 00:09:47.099 That there is no chage 192 00:09:47.119 --> 00:09:49.880 Because once we've inserted this slot 193 00:09:49.880 --> 00:09:52.719 It will perform its action when triggered 194 00:09:52.719 --> 00:09:55.239 Just inserting it alone isn't enough 195 00:09:55.239 --> 00:09:58.320 So, in a way, you can think of the concept of slots 196 00:09:58.320 --> 00:10:01.679 As intercepting or capturing 197 00:10:01.679 --> 00:10:04.239 So, when we shoot the gun 198 00:10:04.239 --> 00:10:06.840 We intercept and handle it through this mechanism 199 00:10:06.840 --> 00:10:09.320 Let's test it briefly in the blueprint 200 00:10:09.320 --> 00:10:10.960 To see how it works 201 00:10:10.960 --> 00:10:13.119 Open up the main character blueprint 202 00:10:13.119 --> 00:10:15.320 TPS Player 203 00:10:15.320 --> 00:10:18.840 Yes, this one 204 00:10:18.840 --> 00:10:22.239 In the legacy input settings 205 00:10:22.239 --> 00:10:25.760 For the left mouse button 206 00:10:25.760 --> 00:10:28.559 it's already registered as Fire 207 00:10:28.559 --> 00:10:31.100 It's not there, let me add one then 208 00:10:31.100 --> 00:10:35.540 let's name it fire like this 209 00:10:36.490 --> 00:10:40.559 Let's do this and register the left mouse button 210 00:10:40.559 --> 00:10:41.719 I'm not going to use this 211 00:10:41.719 --> 00:10:44.159 I just created it for testing purposes 212 00:10:44.159 --> 00:10:45.440 Once you've done it 213 00:10:45.440 --> 00:10:50.760 Let's go back to our main character 214 00:10:50.760 --> 00:10:54.440 Then you would use 'fire' here 215 00:10:54.440 --> 00:10:56.919 I see an event 216 00:10:56.919 --> 00:11:00.520 Since we've configured the enhanced input now 217 00:11:00.520 --> 00:11:02.640 We don't need to use it 218 00:11:02.640 --> 00:11:04.719 But I'm just trying to do a test 219 00:11:04.719 --> 00:11:06.559 When we shoot a gun 220 00:11:06.559 --> 00:11:09.239 In real life we left click on our mouse 221 00:11:09.239 --> 00:11:13.380 Then we play the shoulder movement animation 222 00:11:14.280 --> 00:11:17.799 And this is how 223 00:11:17.799 --> 00:11:22.200 Search Play Anim Montage 224 00:11:22.200 --> 00:11:25.159 This one here 225 00:11:25.159 --> 00:11:26.919 Create a Play Anim Montage node 226 00:11:26.919 --> 00:11:31.200 There are several nodes for playing animation montages 227 00:11:31.200 --> 00:11:34.479 If you search Play Montage 228 00:11:34.479 --> 00:11:36.440 Play Montage is one of them 229 00:11:36.440 --> 00:11:38.039 There's also a Play Anim Montage node 230 00:11:38.039 --> 00:11:39.679 Like so, these are examples 231 00:11:39.679 --> 00:11:42.440 Use whatever suits you 232 00:11:42.440 --> 00:11:44.479 I will use this one 233 00:11:44.479 --> 00:11:46.520 Once you are done, connect these pins 234 00:11:46.520 --> 00:11:50.080 When you press it and indicate that you want it to perform this action 235 00:11:50.080 --> 00:11:52.400 Next, expand it to see 236 00:11:52.400 --> 00:11:53.799 Which montage you want to play 237 00:11:53.799 --> 00:11:57.119 And here you'll see our created montage listed like this 238 00:11:57.119 --> 00:12:00.830 Then, select it like this 239 00:12:01.880 --> 00:12:04.520 So the returned value 240 00:12:04.520 --> 00:12:06.120 It will return the entire time 241 00:12:06.120 --> 00:12:08.400 Playing the actual animation 242 00:12:08.400 --> 00:12:10.760 If there's only one animation montage registered 243 00:12:10.760 --> 00:12:12.719 Only that montage will be played 244 00:12:12.719 --> 00:12:15.760 If there are multiple montages, it returns a combined value 245 00:12:15.760 --> 00:12:19.200 You can control animations using this value if you want to 246 00:12:19.200 --> 00:12:23.719 However, when you control animations 247 00:12:23.719 --> 00:12:26.080 In the middle tab here 248 00:12:26.080 --> 00:12:27.960 You can see it set up like this 249 00:12:27.960 --> 00:12:30.840 In this tab, you can play animations for each section individually 250 00:12:30.840 --> 00:12:32.760 Also, when you look at playing here 251 00:12:32.760 --> 00:12:35.520 You'll see at the very bottom it says Start Section Name 252 00:12:35.520 --> 00:12:38.960 So, sections here refer to segments or intervals 253 00:12:38.960 --> 00:12:41.919 You can control playback for each segment separately 254 00:12:41.919 --> 00:12:44.169 In such cases, it's important to note that 255 00:12:44.169 --> 00:12:45.880 You're not necessarily returning the time of each section 256 00:12:45.880 --> 00:12:48.080 So don't rely too much on that 257 00:12:48.080 --> 00:12:51.359 So there are other ways to handle that 258 00:12:51.359 --> 00:12:54.320 Let's try this method first and see how it goes 259 00:12:54.320 --> 00:12:58.200 After doing this, compile and run it 260 00:12:58.200 --> 00:13:01.000 And when you try it out, the shoulders should go twitch, twitch, twitch 261 00:13:01.000 --> 00:13:03.599 You should be able to see the movement like this 262 00:13:03.599 --> 00:13:06.099 No matter what gun we choose 263 00:13:06.099 --> 00:13:07.640 Pressing the left mouse button 264 00:13:07.640 --> 00:13:10.320 Will make the shoulders twitch like this 265 00:13:10.320 --> 00:13:12.080 Well, there's a bit of an issue with this 266 00:13:12.080 --> 00:13:13.400 Let me walk forward 267 00:13:13.400 --> 00:13:15.840 And shoot my gun 268 00:13:15.840 --> 00:13:18.119 Do you see the problem? 269 00:13:18.119 --> 00:13:20.719 Look at the leg when I shoot 270 00:13:20.719 --> 00:13:23.320 The shoulder movement is played with standing posture 271 00:13:23.320 --> 00:13:24.960 And If you shoot while walking 272 00:13:24.960 --> 00:13:26.910 The leg stops while walking 273 00:13:26.910 --> 00:13:31.150 And tries to stand 274 00:13:31.150 --> 00:13:34.599 So we need to deal with this problem 275 00:13:34.599 --> 00:13:36.679 Well, one way to solve this is 276 00:13:36.679 --> 00:13:38.779 When playing the animation 277 00:13:38.779 --> 00:13:41.279 We can separate the upper and lower body 278 00:13:41.279 --> 00:13:43.400 And play the animation separately 279 00:13:43.400 --> 00:13:48.720 So we'll use this approach to control this 280 00:13:49.420 --> 00:13:52.660 In order to fix this 281 00:13:52.660 --> 00:13:54.710 The base animation 282 00:13:54.710 --> 00:13:57.599 And the animation through this montage 283 00:13:57.599 --> 00:14:01.559 Need to be differentiated and handled separately 284 00:14:01.559 --> 00:14:05.280 In Unreal Engine, if animations are set up like this 285 00:14:05.280 --> 00:14:07.719 They can be temporarily cached 286 00:14:07.719 --> 00:14:09.319 When we typically talk about caching 287 00:14:09.319 --> 00:14:12.799 It refers to temporarily storing data 288 00:14:12.799 --> 00:14:15.379 I'd like to cache the results 289 00:14:15.379 --> 00:14:18.359 From this move FSM if possible 290 00:14:18.359 --> 00:14:22.590 So I'll capture this and set it up for caching like this 291 00:14:23.640 --> 00:14:25.960 I will use New Cached Pose 292 00:14:25.960 --> 00:14:30.520 This way, we can temporarily save it like this 293 00:14:30.520 --> 00:14:33.960 Since the name is move FSM 294 00:14:33.960 --> 00:14:39.200 We should call this save move FSM 295 00:14:41.400 --> 00:14:45.039 Let me jot this down briefly 296 00:14:45.039 --> 00:14:47.039 So, when you retrieve this 297 00:14:47.039 --> 00:14:51.359 If you try using move FSM again 298 00:14:51.359 --> 00:14:53.559 You can retrieve the cached data 299 00:14:53.559 --> 00:14:55.320 It looks like this 300 00:14:55.320 --> 00:14:58.119 As I mentioned earlier 301 00:14:58.119 --> 00:15:01.239 We're going to separate the upper and lower body animations 302 00:15:01.239 --> 00:15:04.599 we'll use the original animation for the lower body 303 00:15:04.599 --> 00:15:08.899 And for the upper body 304 00:15:08.899 --> 00:15:11.119 we'll use the result from the fire slot 305 00:15:11.119 --> 00:15:13.440 We need to divide it into these two parts 306 00:15:13.440 --> 00:15:15.890 But when using this slot 307 00:15:15.890 --> 00:15:18.280 The original animation should come in 308 00:15:18.280 --> 00:15:21.680 And based on that 309 00:15:21.680 --> 00:15:23.520 we'll decide which new animation to select 310 00:15:23.520 --> 00:15:28.440 And then it will return in this structured manner 311 00:15:28.440 --> 00:15:32.000 So, we need to place this cache here as well 312 00:15:32.000 --> 00:15:35.320 You have to fill this up to prevent any errors from occurring 313 00:15:35.320 --> 00:15:39.200 Shall we look at these two animations like this? 314 00:15:39.200 --> 00:15:42.409 Let's disconnect this for a moment 315 00:15:43.409 --> 00:15:47.490 The structure is formed like this 316 00:15:50.340 --> 00:15:53.119 Yes this is the structure 317 00:15:53.119 --> 00:15:56.519 To achieve separating upper and lower body animations 318 00:15:56.519 --> 00:15:58.730 We'll need some functionality that allows us to do that 319 00:15:58.730 --> 00:16:11.409 There's a node called Layered Blend Per Bone for that 320 00:16:12.359 --> 00:16:13.740 We'll be using this one 321 00:16:13.740 --> 00:16:16.440 Add the original animation 322 00:16:16.440 --> 00:16:17.840 Into the base pose 323 00:16:17.840 --> 00:16:22.090 Then add the new animation to be performed 324 00:16:22.090 --> 00:16:24.569 Into the blend pose 325 00:16:26.719 --> 00:16:28.239 This is it 326 00:16:28.239 --> 00:16:31.039 For better understanding 327 00:16:31.039 --> 00:16:33.520 Think of it this way 328 00:16:33.520 --> 00:16:36.080 There is the structure 329 00:16:36.080 --> 00:16:38.760 We will be standing on it 330 00:16:38.760 --> 00:16:42.060 The player's character makes A pose 331 00:16:42.060 --> 00:16:44.799 Standing like this 332 00:16:44.799 --> 00:16:45.599 Little odd 333 00:16:45.599 --> 00:16:48.769 Anyway, the character will be standing like this 334 00:16:48.769 --> 00:16:50.559 The character's pose 335 00:16:50.559 --> 00:16:52.640 We call it the A pose 336 00:16:52.640 --> 00:16:55.320 This here should be its feet 337 00:16:55.320 --> 00:16:58.320 The Bottom center of the feet 338 00:16:58.320 --> 00:17:00.679 Here is where the first pivot point is now 339 00:17:00.679 --> 00:17:01.960 Typically 340 00:17:01.960 --> 00:17:04.040 Here we have these bones 341 00:17:04.040 --> 00:17:05.760 You see bones, like in the feet 342 00:17:05.760 --> 00:17:08.359 Knees, or hips 343 00:17:08.359 --> 00:17:09.520 Typically positioned centrally 344 00:17:09.520 --> 00:17:11.359 The hips 345 00:17:11.359 --> 00:17:15.000 Shoulders 346 00:17:15.000 --> 00:17:16.400 Elbows 347 00:17:16.400 --> 00:17:19.160 Hands, neck, head 348 00:17:19.160 --> 00:17:20.839 Be aware of these skeletons 349 00:17:20.839 --> 00:17:23.160 They can be found in such places like this 350 00:17:23.160 --> 00:17:25.199 So, with these skeletons 351 00:17:25.199 --> 00:17:27.839 The order of the skeleton usually 352 00:17:27.839 --> 00:17:29.880 Goes up from the bottom like this 353 00:17:29.880 --> 00:17:33.520 Earlier we had the base 354 00:17:33.520 --> 00:17:36.160 There was a blend 355 00:17:36.160 --> 00:17:39.479 Let's take a look, we have base pose here 356 00:17:39.479 --> 00:17:41.760 And we have blend pose 357 00:17:41.760 --> 00:17:44.000 Given that 358 00:17:44.000 --> 00:17:45.160 We are starting from the bottom 359 00:17:45.160 --> 00:17:47.319 Then, the bottom should be the base pose 360 00:17:47.319 --> 00:17:49.319 From where to where should the base 361 00:17:49.319 --> 00:17:50.439 And from where to where should be the blend 362 00:17:50.439 --> 00:17:51.959 Is the basic concept of this 363 00:17:51.959 --> 00:17:55.940 So, we need to define a specific point where we establish 364 00:17:55.940 --> 00:17:59.000 The boundary between the blend and the base 365 00:17:59.000 --> 00:18:01.400 So, I'll set the boundary at the middle of the spine 366 00:18:01.400 --> 00:18:04.520 Around the waist area 367 00:18:04.520 --> 00:18:08.000 So, the lower body will be from this spine 368 00:18:08.000 --> 00:18:09.599 Down to the beginning and from the spine 369 00:18:09.599 --> 00:18:11.479 To the remaining end 370 00:18:11.479 --> 00:18:13.920 That's how we'll distinguish it now 371 00:18:13.920 --> 00:18:17.610 Let's take a quick look at the skeleton 372 00:18:19.610 --> 00:18:23.800 Here, you can see an image at the top 373 00:18:23.800 --> 00:18:25.160 If you look here, the one all the way on the left 374 00:18:25.160 --> 00:18:27.239 Is what's really a skeleton 375 00:18:27.239 --> 00:18:28.880 If you click this 376 00:18:28.880 --> 00:18:31.359 You should see the skeletons 377 00:18:31.359 --> 00:18:32.880 There's the pelvis 378 00:18:32.880 --> 00:18:34.000 And then there's the spine 379 00:18:34.000 --> 00:18:36.920 And it's set up like that 380 00:18:36.920 --> 00:18:38.640 So, I'm going to divide it like this 381 00:18:38.640 --> 00:18:41.719 Using the waist spine 01 as the reference point 382 00:18:41.719 --> 00:18:42.800 So spine 01 383 00:18:42.800 --> 00:18:45.520 I'm going to copy the name itself 384 00:18:45.520 --> 00:18:48.199 Copy 385 00:18:48.199 --> 00:18:50.439 Go over here 386 00:18:50.439 --> 00:18:54.040 Select Layered Blend per Bone 387 00:18:54.040 --> 00:18:55.560 Go to the right side 388 00:18:55.560 --> 00:18:57.119 It's set up like this 389 00:18:57.119 --> 00:18:59.520 And in details, we have layer set up 390 00:18:59.520 --> 00:19:01.280 If you expand it 391 00:19:01.280 --> 00:19:03.439 You can add 392 00:19:03.439 --> 00:19:05.079 What's called a branch filter 393 00:19:05.079 --> 00:19:06.760 Click this 394 00:19:06.760 --> 00:19:09.199 If you open it up, it looks like this 395 00:19:09.199 --> 00:19:11.239 Right here, in the name section 396 00:19:11.239 --> 00:19:14.640 Remember the name, Spine 01? 397 00:19:14.640 --> 00:19:17.149 Let's paste it in here 398 00:19:18.199 --> 00:19:19.160 If you put it here 399 00:19:19.160 --> 00:19:21.599 This Spine 01 which is about where the waist is 400 00:19:21.599 --> 00:19:25.680 The body will be distinguished as upper and under parts 401 00:19:25.680 --> 00:19:30.560 And there is a space 402 00:19:30.560 --> 00:19:32.680 It can spin or handle like this 403 00:19:32.680 --> 00:19:34.719 If we have divided bodies 404 00:19:34.719 --> 00:19:38.599 The real animation is made 405 00:19:38.599 --> 00:19:40.040 Using the transform information 406 00:19:40.040 --> 00:19:43.239 The concept is that we will be seeing 407 00:19:43.239 --> 00:19:46.160 The replay of the recorded transform 408 00:19:46.160 --> 00:19:48.160 That is the animation of the Unreal Engine right? 409 00:19:48.160 --> 00:19:51.760 So the spin and whatnot are included in there 410 00:19:51.760 --> 00:19:54.040 So we should enable this 411 00:19:54.040 --> 00:19:56.000 so that the character can make the spin 412 00:19:56.000 --> 00:19:59.479 In the MeshSpace 413 00:19:59.479 --> 00:20:01.760 Here's a simpler way to put it 414 00:20:01.760 --> 00:20:05.040 You have your own space and then there's the world space 415 00:20:05.040 --> 00:20:07.920 So instead of just processing things in world space 416 00:20:07.920 --> 00:20:11.520 you first handle them in your own space 417 00:20:11.520 --> 00:20:12.800 And then move that to the world space 418 00:20:12.800 --> 00:20:14.479 Just remember it like this 419 00:20:14.479 --> 00:20:17.000 So I'll go ahead and do just that 420 00:20:17.000 --> 00:20:20.119 Implement these changes and then compile. 421 00:20:20.119 --> 00:20:21.920 Then after that, we'll need to connect it here 422 00:20:21.920 --> 00:20:26.510 I'll set it up so that this becomes the output like this 423 00:20:27.160 --> 00:20:29.880 So after doing this, when you come back and test it 424 00:20:29.880 --> 00:20:33.119 If you shoot the gun, you'll notice that 425 00:20:33.119 --> 00:20:34.800 The lower body doesn't move anymore 426 00:20:34.800 --> 00:20:38.030 You'll see that only the upper body jerks or moves 427 00:20:40.280 --> 00:20:44.839 Then I'll now try implementing this in C 428 00:20:44.839 --> 00:20:48.880 Excluding the animation is done here 429 00:20:48.880 --> 00:20:51.599 the shooting part was handled by the character 430 00:20:51.599 --> 00:20:55.089 Now I will delete this part 431 00:20:59.239 --> 00:21:03.080 Now let's go to our main character 432 00:21:05.880 --> 00:21:09.160 currently, the shooting action 433 00:21:09.160 --> 00:21:12.880 Is handled by the protagonist 434 00:21:12.880 --> 00:21:16.000 So, when we go to the protagonist's header file to process it 435 00:21:16.000 --> 00:21:21.000 Ultimately the animation will be controlled 436 00:21:21.000 --> 00:21:23.079 Through that when shooting the gun 437 00:21:23.079 --> 00:21:24.479 Right? 438 00:21:24.479 --> 00:21:26.599 So, it's set up like this 439 00:21:26.599 --> 00:21:30.239 I'll implement it on the TPS player side for now 440 00:21:30.239 --> 00:21:33.079 If you come down like this 441 00:21:33.079 --> 00:21:45.119 In the bottom, write, I want to play a montage of 442 00:21:45.119 --> 00:21:48.880 Shoulder movement when shooting 443 00:21:48.880 --> 00:21:52.280 So, we want this 444 00:21:52.280 --> 00:21:54.000 Then, we need to make a montage 445 00:21:54.000 --> 00:22:01.520 UPROPERTY, EditAnywhere 446 00:22:01.520 --> 00:22:03.040 Class and then 447 00:22:03.040 --> 00:22:09.400 UAnimMontage 448 00:22:09.400 --> 00:22:11.239 With this 449 00:22:11.239 --> 00:22:13.969 This one we use Fire 450 00:22:13.969 --> 00:22:18.679 FireAnimMontage 451 00:22:18.679 --> 00:22:25.980 Like so 452 00:22:32.530 --> 00:22:35.560 And then 453 00:22:35.560 --> 00:22:38.959 We go back to our character 454 00:22:38.959 --> 00:22:43.800 We can find the shooting part over here 455 00:22:43.800 --> 00:22:44.920 Right here 456 00:22:44.920 --> 00:22:46.640 OnIAFire 457 00:22:46.640 --> 00:22:49.319 Right here we shoot guns 458 00:22:49.319 --> 00:22:52.160 Doesn't matter what kind of weapon it is for the shoulder movement 459 00:22:52.160 --> 00:22:55.359 So, we write it here 460 00:22:55.359 --> 00:22:58.479 Use function called PlayAnimMontage 461 00:22:58.479 --> 00:23:03.960 Let's add FireAnimMontage here 462 00:23:07.760 --> 00:23:10.439 And we should do this when the value is not null 463 00:23:10.439 --> 00:23:14.599 So, check for the null 464 00:23:14.599 --> 00:23:19.439 Write it like this 465 00:23:19.439 --> 00:23:22.920 Compile this 466 00:23:30.370 --> 00:23:35.279 Come to the main character and in the class default 467 00:23:38.287 --> 00:23:39.199 Right here 468 00:23:39.199 --> 00:23:44.429 In here let's put our custom made Montage Fire 469 00:23:47.479 --> 00:23:51.079 When you start the game, it works just fine 470 00:23:51.079 --> 00:23:53.490 Shoulder twitches 471 00:23:56.640 --> 00:23:57.936 Upper and under body parts are separated well 472 00:23:57.936 --> 00:24:01.386 Camera motion handling while shooting 473 00:24:01.689 --> 00:24:05.400 Let's synchronize the gun and try it out 474 00:24:05.400 --> 00:24:07.199 Right now, the gun is separated 475 00:24:07.199 --> 00:24:08.479 If you look here 476 00:24:08.479 --> 00:24:12.769 I'll attach the gun directly to the hand and try controlling it that way 477 00:24:15.019 --> 00:24:16.640 Do you remember when we added the socket 478 00:24:16.640 --> 00:24:21.560 For shooting the gun to handle this? 479 00:24:21.560 --> 00:24:23.760 So, we'll add the socket here 480 00:24:23.760 --> 00:24:26.520 And use the coordinates for that 481 00:24:26.520 --> 00:24:29.170 In a similar way 482 00:24:29.170 --> 00:24:31.560 We'll create a socket on the hand for each of these weapons 483 00:24:31.560 --> 00:24:34.010 And attach them accordingly 484 00:24:34.010 --> 00:24:36.160 To control them like this 485 00:24:36.160 --> 00:24:38.010 If you look at the mesh 486 00:24:38.010 --> 00:24:41.760 this is the one the character uses 487 00:24:41.760 --> 00:24:44.599 Let's double click to open it 488 00:24:44.599 --> 00:24:47.359 And If you look, there's the skeleton 489 00:24:47.359 --> 00:24:50.920 I will attach it on the right hand of the skeleton 490 00:24:50.920 --> 00:24:53.359 Find the right hand 491 00:24:53.359 --> 00:24:56.040 It's not easy to find 492 00:24:56.040 --> 00:25:00.119 From here, you should look for the right hand 493 00:25:00.119 --> 00:25:03.390 Let's search for it 494 00:25:03.890 --> 00:25:07.560 Let's try hand 495 00:25:07.560 --> 00:25:09.319 There, I see the hand 496 00:25:09.319 --> 00:25:11.479 The name is Hand r 497 00:25:11.479 --> 00:25:14.280 I'll add a socket here 498 00:25:14.280 --> 00:25:16.599 Like this 499 00:25:16.599 --> 00:25:17.900 Right here 500 00:25:17.900 --> 00:25:20.400 Select this and right click on it 501 00:25:20.400 --> 00:25:23.809 Use Add Socket to add a new socket 502 00:25:26.359 --> 00:25:28.040 So, add one like this 503 00:25:28.040 --> 00:25:30.920 Let's use the name 504 00:25:30.920 --> 00:25:33.400 Hand rSocket 505 00:25:33.400 --> 00:25:35.239 Make sure to save it 506 00:25:35.239 --> 00:25:38.400 Let's go ahead and save then come back 507 00:25:38.400 --> 00:25:41.640 Let's go to the source file 508 00:25:41.640 --> 00:25:45.710 I'll move to the character's constructor to check this 509 00:25:47.060 --> 00:25:53.319 Here you can see that we have the gun mesh and the sniper rifle mesh like this 510 00:25:53.319 --> 00:25:57.640 We've created them and attached them like this 511 00:25:57.640 --> 00:25:59.400 You can see them in two places 512 00:25:59.400 --> 00:26:04.479 When attaching these, you can see here that as the second parameter 513 00:26:04.479 --> 00:26:07.280 You can input the socket name like this 514 00:26:07.280 --> 00:26:09.479 Then if you just write the socket name here 515 00:26:09.479 --> 00:26:11.479 It will attach to that socket 516 00:26:11.479 --> 00:26:14.239 So I'll write the name here 517 00:26:14.239 --> 00:26:16.800 Let's say Text 518 00:26:16.800 --> 00:26:19.119 so doing it like this 519 00:26:19.119 --> 00:26:20.680 you can replace the name hand rSocket if you want 520 00:26:20.680 --> 00:26:24.920 But I'll go ahead and use the automatically generated name for now 521 00:26:24.920 --> 00:26:26.040 Do it like this 522 00:26:26.040 --> 00:26:29.950 And here as well, I'll attach it the same way 523 00:26:31.350 --> 00:26:33.839 I'll restart Unreal Engine once 524 00:26:33.839 --> 00:26:37.150 And then build it here 525 00:26:50.500 --> 00:26:54.180 Let's go ahead and run it 526 00:27:00.680 --> 00:27:02.789 Let's go to the character 527 00:27:08.439 --> 00:27:11.079 If you look at it, the gun is attached 528 00:27:11.079 --> 00:27:13.479 But it's way up there 529 00:27:13.479 --> 00:27:16.329 So we need to really attach it 530 00:27:16.329 --> 00:27:18.319 And adjust its location 531 00:27:18.319 --> 00:27:20.920 So, let me proceed with these tasks 532 00:27:20.920 --> 00:27:23.439 Let's do this one by one 533 00:27:23.439 --> 00:27:24.680 Temporarily turn the sniper rifle off 534 00:27:24.680 --> 00:27:26.520 Let's set up the gun first 535 00:27:26.520 --> 00:27:33.319 I'll turn the visible of the sniper rifle off 536 00:27:33.319 --> 00:27:36.520 And it will be hard to control if it moves 537 00:27:36.520 --> 00:27:40.959 If you look here in the mesh, you can stop the animation 538 00:27:40.959 --> 00:27:42.559 Expand this 539 00:27:42.559 --> 00:27:45.880 Expand the advanced settings in animation 540 00:27:45.880 --> 00:27:47.199 You can make a pose 541 00:27:47.199 --> 00:27:49.760 Pause the character 542 00:27:49.760 --> 00:27:53.760 Now let's place the gun 543 00:27:53.760 --> 00:27:58.860 bring it down like this 544 00:27:59.610 --> 00:28:03.099 And place it nicely 545 00:28:18.599 --> 00:28:22.079 We've placed it 546 00:28:22.079 --> 00:28:26.920 If you use the menu over here, it would be better 547 00:28:26.920 --> 00:28:29.959 With Perspective menu, like front, you can micro manage the location 548 00:28:29.959 --> 00:28:33.880 I think it's good enough 549 00:28:33.880 --> 00:28:36.959 Go to the right side perspective 550 00:28:36.959 --> 00:28:40.319 adjust a bit 551 00:28:40.319 --> 00:28:43.439 If it's too big,let's turn off this setting and adjust the spacing 552 00:28:43.439 --> 00:28:45.689 Turn this thing off 553 00:28:45.689 --> 00:28:48.760 Try to place it nicely 554 00:28:51.760 --> 00:28:53.319 Feels like the gun is too big 555 00:28:53.319 --> 00:28:54.560 Will go for it 556 00:28:54.560 --> 00:28:56.520 Now second one, will do the same for the sniper rifle 557 00:28:56.520 --> 00:28:59.520 Turn off the gun as well for this one 558 00:28:59.520 --> 00:29:02.959 Visible routine 559 00:29:02.959 --> 00:29:05.000 Turn off the reserve like this 560 00:29:05.000 --> 00:29:08.199 And then turn the sniper rifle on 561 00:29:08.199 --> 00:29:12.319 This one also is out of place 562 00:29:12.319 --> 00:29:16.079 Place it near where it's supposed to be 563 00:29:22.079 --> 00:29:27.280 Just like before, front perspective 564 00:29:27.280 --> 00:29:30.249 I'll give it a little spin 565 00:29:46.599 --> 00:29:51.089 Place it in a suitable position 566 00:30:04.239 --> 00:30:08.400 Just place it nicely like this, and it should be good 567 00:30:08.400 --> 00:30:09.640 Now, once you are done with the setting 568 00:30:09.640 --> 00:30:11.160 Now we should make sure it's fully visible 569 00:30:11.160 --> 00:30:13.640 Turn on the visible routine again 570 00:30:13.640 --> 00:30:16.440 The animation with the pose 571 00:30:16.440 --> 00:30:19.320 Must be placed on the right spot 572 00:30:21.920 --> 00:30:28.199 And then you will see it working well 573 00:30:28.199 --> 00:30:30.940 The camera follows well 574 00:30:30.940 --> 00:30:34.380 Press number 2, the gun is set nicely 575 00:30:36.880 --> 00:30:40.680 By doing this, you can synchronize the animation with the gun's position 576 00:30:40.680 --> 00:30:44.079 And handle it smoothly and naturally 577 00:30:44.079 --> 00:30:47.179 Then adding a slight shake when shooting the gun 578 00:30:47.179 --> 00:30:50.719 can enhance the impactfulness 579 00:30:50.719 --> 00:30:54.019 So, I'll go ahead and try creating a feature that shakes 580 00:30:54.019 --> 00:30:56.439 The camera like this for added effect 581 00:30:56.439 --> 00:30:58.400 I'll start by creating the blueprint for this 582 00:30:58.400 --> 00:31:01.810 Try right clicking here like this 583 00:31:03.160 --> 00:31:04.839 Find Blueprint class 584 00:31:04.839 --> 00:31:07.800 Then select All classes like this 585 00:31:07.800 --> 00:31:12.809 I'll search for camera shake here 586 00:31:14.959 --> 00:31:20.359 Okay, so there's a Camera Shake Base available 587 00:31:20.359 --> 00:31:24.680 Alright, select this Camera Shake Base, and then click Select 588 00:31:24.680 --> 00:31:32.920 Okay, then I'll name this BP CameraShake 589 00:31:35.520 --> 00:31:38.640 if you double click to open it 590 00:31:38.640 --> 00:31:42.160 you'll see it looks something like this, empty 591 00:31:42.160 --> 00:31:44.520 But here on the right side in the details 592 00:31:44.520 --> 00:31:47.520 You'll see there's something called Camera Shake Pattern 593 00:31:47.520 --> 00:31:49.520 If you look at the root camera pattern 594 00:31:49.520 --> 00:31:52.479 You'll see there are four options listed here like this 595 00:31:52.479 --> 00:31:54.319 Then if you look below 596 00:31:54.319 --> 00:31:56.839 You'll see there's this Wave Oscillator 597 00:31:56.839 --> 00:31:59.989 Which is what we typically think of as 598 00:31:59.989 --> 00:32:01.880 Camera vibration or oscillation 599 00:32:01.880 --> 00:32:05.230 So creating an amplitude with this allows us 600 00:32:05.230 --> 00:32:08.880 To shake the camera using that concept 601 00:32:08.880 --> 00:32:11.680 If you look at the second one, there's something called a sequence 602 00:32:11.680 --> 00:32:16.079 Sequence, as the name suggests, is used to create animations 603 00:32:16.079 --> 00:32:19.040 We typically refer to animation sequences as animation sequences 604 00:32:19.040 --> 00:32:19.920 Right? 605 00:32:19.920 --> 00:32:21.359 Okay, so we have this here 606 00:32:21.359 --> 00:32:24.560 The concept of Perlin noise 607 00:32:24.560 --> 00:32:28.079 Involves defining a specific region 608 00:32:28.079 --> 00:32:30.680 And then varying the intensity within that area 609 00:32:30.680 --> 00:32:34.880 It uses values between 0 and 1 as coordinates 610 00:32:34.880 --> 00:32:36.640 It can also be used for rotation 611 00:32:36.640 --> 00:32:40.079 So it represents randomness in this way 612 00:32:40.079 --> 00:32:42.199 Think of it as embodying this concept 613 00:32:42.199 --> 00:32:44.499 Finally, Composite refers to using 614 00:32:44.499 --> 00:32:47.439 A combination of these three concepts together 615 00:32:47.439 --> 00:32:50.760 So, let's go ahead and create a Wave Oscillator first 616 00:32:50.760 --> 00:32:54.339 Click on this 617 00:32:55.839 --> 00:32:59.400 If you expand it, it looks like this 618 00:32:59.400 --> 00:33:02.550 Then I'll adjust just the rotation value once 619 00:33:02.550 --> 00:33:05.280 I'll go ahead and adjust 620 00:33:05.280 --> 00:33:07.980 The rotation values to see how it moves 621 00:33:07.980 --> 00:33:13.070 It's designed so you can adjust three values, pitch yaw and roll 622 00:33:14.920 --> 00:33:17.359 So 623 00:33:17.359 --> 00:33:20.359 I'll set this one 624 00:33:20.359 --> 00:33:23.560 At the top to 1 625 00:33:23.560 --> 00:33:27.000 Usually, amplitude refers to intensity 626 00:33:27.000 --> 00:33:32.079 And frequency refers to the concept of frequency or rate 627 00:33:32.079 --> 00:33:37.430 So you can use this to control as needed 628 00:33:39.680 --> 00:33:44.359 Set Pitch to 0.5 629 00:33:44.359 --> 00:33:46.710 And Frequency to 10 like this 630 00:33:47.760 --> 00:33:51.160 And Yaw controls the rotation from side to side, like nodding up and down 631 00:33:51.160 --> 00:33:52.680 I mean yaw rotation 632 00:33:52.680 --> 00:33:53.719 I won't do this one 633 00:33:53.719 --> 00:33:56.439 Let's set this one to 0 634 00:33:56.439 --> 00:33:57.839 In a sense, pitch corresponds to nodding up and down 635 00:33:57.839 --> 00:33:58.640 While yaw corresponds to swaying side to side 636 00:33:58.640 --> 00:34:02.160 Think of this as a swaying motion 637 00:34:02.160 --> 00:34:06.479 The thing is how are we going to rotate the camera? 638 00:34:06.479 --> 00:34:12.879 And I'll set Roll to just 0.2 like this 639 00:34:12.879 --> 00:34:17.479 Set this one to 0 640 00:34:17.479 --> 00:34:22.040 Next, there's the FOV and timing options here 641 00:34:22.040 --> 00:34:23.919 In the timing section, it looks like this 642 00:34:23.919 --> 00:34:26.479 The duration is set to 1 here 643 00:34:26.479 --> 00:34:28.520 And there's also a blend time like this 644 00:34:28.520 --> 00:34:31.439 So, I'll reduce the blend time a bit 645 00:34:31.439 --> 00:34:33.479 This one with 0.05 646 00:34:33.479 --> 00:34:37.000 You can think of the blend time as similar to when you blend animations earlier 647 00:34:37.000 --> 00:34:38.800 You have the camera 648 00:34:38.800 --> 00:34:40.439 In its original controlled state 649 00:34:40.439 --> 00:34:43.679 And then you want it to momentarily shake 650 00:34:43.679 --> 00:34:45.439 Before returning to its original state 651 00:34:45.439 --> 00:34:48.879 That's what we're talking about when we mention the blend time 652 00:34:48.879 --> 00:34:52.229 Make it short, like 0.05 seconds 653 00:34:52.229 --> 00:34:55.320 Let's set it up like this and give it a try 654 00:34:55.320 --> 00:34:58.719 Since this is now in blueprint 655 00:34:58.719 --> 00:35:01.719 To use it in the source files 656 00:35:01.719 --> 00:35:04.069 we'll need to create a variable for it 657 00:35:04.069 --> 00:35:06.919 And retrieve it for use 658 00:35:06.919 --> 00:35:13.239 So let's go to the character 659 00:35:13.239 --> 00:35:14.320 Not the animation 660 00:35:14.320 --> 00:35:16.399 And handle it from this side 661 00:35:16.399 --> 00:35:19.220 Under the montage 662 00:35:22.270 --> 00:35:27.470 We need to declare variables 663 00:35:29.120 --> 00:35:35.990 For handling camera shake 664 00:35:36.040 --> 00:35:40.479 So we'll also use U Property for this 665 00:35:40.479 --> 00:35:44.500 Edit Anywhere 666 00:35:44.500 --> 00:35:46.239 I'm going to use T SubclassOf 667 00:35:46.239 --> 00:35:49.120 Instead of 'class' for this 668 00:35:49.120 --> 00:35:51.080 That's also the concept of U Class 669 00:35:51.080 --> 00:35:53.080 So I'll call it a class 670 00:35:53.080 --> 00:35:56.730 Basically, that will be UCameraShakeBase 671 00:35:57.980 --> 00:35:59.280 Here it is 672 00:35:59.280 --> 00:36:01.159 Set up like this 673 00:36:01.159 --> 00:36:06.489 Alright, I'll name this camera shake 674 00:36:06.489 --> 00:36:10.199 Let's go to where we shot the gun earlier 675 00:36:10.199 --> 00:36:14.639 It should be located below 676 00:36:15.439 --> 00:36:19.739 Here, this is it 677 00:36:21.639 --> 00:36:24.879 Let's make sure to include the shake here as well when we do this 678 00:36:24.879 --> 00:36:28.929 So we'll only do the camera shake 679 00:36:28.929 --> 00:36:32.160 When the shake variable is not null 680 00:36:33.210 --> 00:36:35.280 So to shake the camera 681 00:36:35.280 --> 00:36:36.840 We need to access 682 00:36:36.840 --> 00:36:40.280 The player controller's camera manager 683 00:36:40.280 --> 00:36:43.239 Or player camera manager 684 00:36:43.239 --> 00:36:48.189 I'll use Get World 685 00:36:48.189 --> 00:36:52.360 To retrieve Get First Player Controller 686 00:36:52.360 --> 00:36:59.479 Here you can see there's a Player Camera Manager 687 00:36:59.479 --> 00:37:07.679 Here you'll find constants like Start Camera Shake 688 00:37:07.679 --> 00:37:09.600 Here we'll put in 689 00:37:09.600 --> 00:37:13.199 the T-SubclassOf type we created earlier 690 00:37:13.199 --> 00:37:16.929 Let's assign camera shake here like this 691 00:37:18.879 --> 00:37:21.779 Well, actually, going straight ahead like this 692 00:37:21.779 --> 00:37:24.399 Can be a bit risky 693 00:37:24.399 --> 00:37:27.879 For example, while it's unlikely 694 00:37:27.879 --> 00:37:29.729 Most of the time when we fetch this 695 00:37:29.729 --> 00:37:31.639 It could be null, right? 696 00:37:31.639 --> 00:37:34.719 So, in cases like this, it's often a good practice 697 00:37:34.719 --> 00:37:37.019 To assign it to a variable 698 00:37:37.019 --> 00:37:40.399 Check if it's null, and then proceed accordingly 699 00:37:40.399 --> 00:37:43.639 Well, since we don't expect that possibility 700 00:37:43.639 --> 00:37:47.150 I'll go ahead and write it like this 701 00:37:49.800 --> 00:37:53.480 I'll go ahead and compile it in Unreal 702 00:38:02.080 --> 00:38:05.760 And we'll have to fill up the value 703 00:38:05.760 --> 00:38:12.840 Here you select Class Defaults 704 00:38:12.840 --> 00:38:14.959 Right here 705 00:38:14.959 --> 00:38:18.320 Then choose our BP Camera Shake that we created 706 00:38:18.320 --> 00:38:22.159 Replace it with that, compile 707 00:38:22.159 --> 00:38:26.239 And then run it to see if the camera shakes when you shoot 708 00:38:26.239 --> 00:38:28.760 It shakes quite vigorously 709 00:38:28.760 --> 00:38:30.810 Now you can adjust 710 00:38:30.810 --> 00:38:34.660 These shaking values to your liking 711 00:38:35.760 --> 00:38:38.360 Let's adjust the settings then 712 00:38:38.399 --> 00:38:41.589 I'll set this one to 0.1 713 00:38:42.439 --> 00:38:45.089 this one to 1 714 00:38:49.439 --> 00:38:51.560 And it seems the duration of the shake is a bit long 715 00:38:51.560 --> 00:38:54.560 So I'll reduce it to 0.1 716 00:38:54.560 --> 00:38:56.760 This one here, maybe we can speed it up a bit 717 00:38:56.760 --> 00:38:57.800 Let's try 0.5 718 00:38:57.800 --> 00:38:59.280 You can continue tweaking these values 719 00:38:59.280 --> 00:39:02.239 Until you find the right fit 720 00:39:02.239 --> 00:39:04.949 If it's too intense, it might not feel right 721 00:39:08.399 --> 00:39:10.360 So adjusting like this 722 00:39:10.360 --> 00:39:13.510 Should help you 723 00:39:13.510 --> 00:39:16.569 Decide what works best 724 00:39:17.919 --> 00:39:20.080 let's try making some sound 725 00:39:20.080 --> 00:39:25.019 To make sound, we need to look at 726 00:39:25.769 --> 00:39:29.239 Where the sound files are located in our model 727 00:39:29.239 --> 00:39:31.619 Right here 728 00:39:32.919 --> 00:39:33.800 Right here 729 00:39:33.800 --> 00:39:35.120 Rifle 730 00:39:35.120 --> 00:39:38.320 Let me go ahead and play this sound for you 731 00:39:38.320 --> 00:39:42.719 Similarly, let's go to the main character header file 732 00:39:42.719 --> 00:39:44.760 Right here 733 00:39:44.760 --> 00:39:48.919 Put in UPROPERTY 734 00:39:48.919 --> 00:39:51.600 And EditAnywhere 735 00:39:51.600 --> 00:39:53.560 Write Class 736 00:39:53.560 --> 00:39:57.959 USoundbase 737 00:39:57.959 --> 00:40:01.239 Like this 738 00:40:01.239 --> 00:40:05.740 And then BulletSound 739 00:40:13.040 --> 00:40:15.740 So we've been filling this out 740 00:40:15.740 --> 00:40:18.080 In the blueprint all along 741 00:40:18.080 --> 00:40:22.040 Shall we fill this in the constructor this time? 742 00:40:22.040 --> 00:40:25.239 Let's go to the constructor of the protagonist here 743 00:40:25.289 --> 00:40:30.650 Come down to the bottom, and fill it out 744 00:40:30.650 --> 00:40:35.719 We'll also use Constructor Helpers for this 745 00:40:35.719 --> 00:40:40.159 Put in FObjectFinder 746 00:40:40.159 --> 00:40:45.360 This one should be USoundBase 747 00:40:45.360 --> 00:40:49.439 And then TempSound 748 00:40:49.439 --> 00:40:53.479 I mean TempBulletSound 749 00:40:53.479 --> 00:40:56.170 I'll name it like this 750 00:40:59.120 --> 00:41:01.560 Then we need to know the path for that 751 00:41:01.560 --> 00:41:06.000 Select it like this, and you can copy the reference for this as well 752 00:41:06.000 --> 00:41:07.800 I'll paste it here 753 00:41:07.800 --> 00:41:09.560 And it should look like this 754 00:41:09.560 --> 00:41:11.320 And for the asset 755 00:41:11.320 --> 00:41:14.879 Like this, using F-Object Finder from Constructor Helpers 756 00:41:14.879 --> 00:41:17.399 Alternatively, you can use F-Class Finder 757 00:41:17.399 --> 00:41:19.520 To read everything at once 758 00:41:19.520 --> 00:41:22.000 After doing this 759 00:41:22.000 --> 00:41:26.879 Write If TempBulletSound 760 00:41:26.879 --> 00:41:31.159 If it succeeded 761 00:41:31.159 --> 00:41:32.959 Assign BulletSound to the variables 762 00:41:32.959 --> 00:41:40.399 You can directly insert the object of 763 00:41:40.399 --> 00:41:43.230 Temp-Bullet Sound here 764 00:41:45.080 --> 00:41:48.239 You just need to insert it like this 765 00:41:48.239 --> 00:41:50.639 There's also the option to insert it through a function like this 766 00:41:50.639 --> 00:41:51.840 They are the same 767 00:41:51.840 --> 00:41:54.800 Ultimately, since the object's type is 768 00:41:54.800 --> 00:41:57.159 Exactly what we want as the sound base 769 00:41:57.159 --> 00:41:59.910 You can simply insert it like this 770 00:42:01.560 --> 00:42:03.919 Do this and save it 771 00:42:03.919 --> 00:42:06.159 Compile again and see the result 772 00:42:06.159 --> 00:42:07.679 But since we've made change in the header file 773 00:42:07.679 --> 00:42:13.050 In that case, it's usually a good idea to reopen Unreal Engine 774 00:42:21.000 --> 00:42:23.919 Then, we should definitely try shooting the gun to see 775 00:42:23.919 --> 00:42:28.159 Let's move down and shoot the gun 776 00:42:28.159 --> 00:42:30.639 Right here 777 00:42:30.639 --> 00:42:31.959 I'll make the sound 778 00:42:31.959 --> 00:42:35.959 If Bullet Sound is not null 779 00:42:35.959 --> 00:42:39.479 Then we can proceed like this 780 00:42:39.479 --> 00:42:45.000 UGameplayStatics PlaySound2D 781 00:42:45.000 --> 00:42:46.560 Let's use this one 782 00:42:46.560 --> 00:42:47.560 Here I add in the world 783 00:42:47.560 --> 00:42:49.479 And then the sound file 784 00:42:49.479 --> 00:42:55.159 Then, put in GetWorld and BulletSound 785 00:42:55.159 --> 00:43:02.539 Let's compile this in Unreal Engine and see the results 786 00:43:14.639 --> 00:43:19.479 Run it and you should see that the sound plays correctly 787 00:43:23.179 --> 00:43:27.720 I will now summarize the content we learned in this chapter 788 00:43:28.125 --> 00:43:29.325 Animation Montage creation Animation Montage Produce animation Montage using the Fire Rifle Inronsights asset in the Animations folder 789 00:43:29.325 --> 00:43:30.625 Drag Fire Rifle Ironsights from the asset browser and place it into the slot Modified the animation montage blend time 790 00:43:30.625 --> 00:43:31.775 An animation montage applied via blueprint Inserted a shooting animation into the middle of the existing animations in the ABP TPSP animation blueprint 791 00:43:31.775 --> 00:43:32.975 Set spine 01 as the pivot point to divide the upper body for shooting and the lower body for movement animations in handling 792 00:43:32.975 --> 00:43:34.125 Blueprint applied animation montage Declared the shooting animation montage and its playback function in TPSPlayer.h file 793 00:43:34.125 --> 00:43:35.125 Added the implementation of the shooting animation playback function in TPSPlayer.cpp file Assign Montage_Fire to the Fire Anim Montage field in the details panel of BP TPSPlayer 794 00:43:35.125 --> 00:43:36.075 Handling camera motion during shooting Handling camera motion during shooting perspective Create a Blueprint Class inheriting from CameraShakeBase and name it BP CameraShake 795 00:43:36.075 --> 00:43:36.975 Set Root Shake Pattern to Wave Oscillator Camera Shake Pattern and assign values to each property 796 00:43:36.975 --> 00:43:37.925 Declared properties for camera shake handling in TPSPlayer.h file Using the GetFirstPlayerController function to access the PlayerCameraManager 797 00:43:37.925 --> 00:43:38.825 Getting the member variable and passing it as an argument to the StartCameraShake function 798 00:43:38.825 --> 00:43:39.725 In the details panel, assign BP CameraShake to the Camera Shake field Handling the playback of shooting sound Added a variable for bullet firing sound in TPSPlayer.h file 799 00:43:39.725 --> 00:43:40.675 Declared a variable TempBulletSound of type USoundBase using ConstructorHelpers' FObjectFinder in TPSPlayer.h 800 00:43:40.675 --> 00:43:41.625 Copied and pasted the asset path for Rifle Sound Wave into TEXT as a constructor argument When the load is successful using the Succeeded function 801 00:43:41.625 --> 00:43:42.575 Assigned the loaded value to the BulletSound variable Played BulletSound using UGameplayStatics' PlaySound2D function