1 00:00:06,320 --> 00:00:11,499 [Music] 2 00:00:15,679 --> 00:00:19,439 hello everyone and welcome back to the 3 00:00:17,119 --> 00:00:21,439 kia ora theater at linux conference 4 00:00:19,439 --> 00:00:22,480 australia 2022 5 00:00:21,439 --> 00:00:25,439 uh 6 00:00:22,480 --> 00:00:26,480 our next presentation is pre-recorded uh 7 00:00:25,439 --> 00:00:27,680 so 8 00:00:26,480 --> 00:00:29,199 uh 9 00:00:27,680 --> 00:00:30,960 i'm the only person talking to you right 10 00:00:29,199 --> 00:00:32,399 now but we will get pre-recorder paris 11 00:00:30,960 --> 00:00:33,360 in here soon 12 00:00:32,399 --> 00:00:35,520 um 13 00:00:33,360 --> 00:00:36,960 so dr paris buttfield addison is the 14 00:00:35,520 --> 00:00:39,440 co-founder of independent game 15 00:00:36,960 --> 00:00:41,520 development studio secret lab today he 16 00:00:39,440 --> 00:00:43,520 is here to help us learn about godot 17 00:00:41,520 --> 00:00:46,000 oh i didn't check how to pronounce godot 18 00:00:43,520 --> 00:00:47,760 we'll learn in the talk uh take a 19 00:00:46,000 --> 00:00:50,000 tour of its features and powerful 20 00:00:47,760 --> 00:00:52,960 scripting system and quickly build a 21 00:00:50,000 --> 00:00:55,120 game uh showcasing the godot editor for 22 00:00:52,960 --> 00:00:56,719 mac os windows and linux 23 00:00:55,120 --> 00:00:58,879 paris is available in chat throughout so 24 00:00:56,719 --> 00:01:03,199 feel free to ask questions as we go take 25 00:00:58,879 --> 00:01:03,199 it away with your pre-recorded paris 26 00:01:08,479 --> 00:01:13,360 hi everyone welcome to let's make a game 27 00:01:11,439 --> 00:01:15,920 my name is paris but for edison 28 00:01:13,360 --> 00:01:17,200 you can tweet me at paris ba i'd love to 29 00:01:15,920 --> 00:01:18,640 hear from you 30 00:01:17,200 --> 00:01:20,560 please feel free to do that and let me 31 00:01:18,640 --> 00:01:22,240 know what you think questions about godo 32 00:01:20,560 --> 00:01:23,840 anything else or just want to tell me 33 00:01:22,240 --> 00:01:24,880 you like my glasses which is a common 34 00:01:23,840 --> 00:01:26,560 comment 35 00:01:24,880 --> 00:01:29,040 i am a video game developer 36 00:01:26,560 --> 00:01:30,960 uh best known for working at secret lab 37 00:01:29,040 --> 00:01:32,320 which worked the night in the woods lots 38 00:01:30,960 --> 00:01:34,479 of o'reilly books lots of technical 39 00:01:32,320 --> 00:01:35,680 books uh and the younesman narrative 40 00:01:34,479 --> 00:01:37,119 game tool 41 00:01:35,680 --> 00:01:38,960 today i'm here to talk to you about a 42 00:01:37,119 --> 00:01:41,280 fantastic and completely free and open 43 00:01:38,960 --> 00:01:42,399 source game engine named gotto or godot 44 00:01:41,280 --> 00:01:43,280 depending on how you pronounce these 45 00:01:42,399 --> 00:01:46,079 things 46 00:01:43,280 --> 00:01:48,159 godot is a fully open source project 47 00:01:46,079 --> 00:01:49,840 that really genuinely competes with the 48 00:01:48,159 --> 00:01:51,680 big mainstream commercial video game 49 00:01:49,840 --> 00:01:53,600 engines like unreal and unity it is 50 00:01:51,680 --> 00:01:54,720 named after the play with pictured here 51 00:01:53,600 --> 00:01:57,680 starring patrick stewart and ian 52 00:01:54,720 --> 00:01:59,520 mckellen that was a fantastic player uh 53 00:01:57,680 --> 00:02:02,399 but starring many people over the years 54 00:01:59,520 --> 00:02:03,759 it is a powerful little gaming engine uh 55 00:02:02,399 --> 00:02:05,680 it is a project of the software freedom 56 00:02:03,759 --> 00:02:06,640 conservancy uh the software very 57 00:02:05,680 --> 00:02:08,720 conservatively shepherds a lot of 58 00:02:06,640 --> 00:02:10,080 projects and godot is one of them they 59 00:02:08,720 --> 00:02:11,599 make sure that the project is compliant 60 00:02:10,080 --> 00:02:12,640 with their open source licenses and 61 00:02:11,599 --> 00:02:14,239 other people are compliant with the 62 00:02:12,640 --> 00:02:16,239 license when they're using them 63 00:02:14,239 --> 00:02:18,160 but godo really is an astonishingly 64 00:02:16,239 --> 00:02:20,239 powerful game engine it is one of my 65 00:02:18,160 --> 00:02:22,080 favorite free and open source projects 66 00:02:20,239 --> 00:02:24,560 it has many of the same features as the 67 00:02:22,080 --> 00:02:26,640 big commercial projects uh and really 68 00:02:24,560 --> 00:02:28,879 competes with them but it's entirely 69 00:02:26,640 --> 00:02:30,800 free in open source it has good ui good 70 00:02:28,879 --> 00:02:32,560 ux uh it's 71 00:02:30,800 --> 00:02:34,080 quite easy to develop with it's powerful 72 00:02:32,560 --> 00:02:36,000 it can deploy to almost every platform 73 00:02:34,080 --> 00:02:37,360 you can think so uh today i'm going to 74 00:02:36,000 --> 00:02:39,680 take you through building a little game 75 00:02:37,360 --> 00:02:42,000 very simple game from scratch 76 00:02:39,680 --> 00:02:43,760 and talk about how and why you can use 77 00:02:42,000 --> 00:02:44,879 godo to do this sort of thing 78 00:02:43,760 --> 00:02:46,959 hopefully by the end you'll see why it's 79 00:02:44,879 --> 00:02:48,000 really powerful and how it's easy to use 80 00:02:46,959 --> 00:02:49,360 i'm not going to 81 00:02:48,000 --> 00:02:50,560 structure this tutorial this is more 82 00:02:49,360 --> 00:02:52,000 just going to be 83 00:02:50,560 --> 00:02:53,440 enthusing you about gotto so don't 84 00:02:52,000 --> 00:02:55,360 necessarily try and follow along i 85 00:02:53,440 --> 00:02:56,640 really hope you enjoy it's a really good 86 00:02:55,360 --> 00:02:57,840 fun relatively cheap hobby to build 87 00:02:56,640 --> 00:02:59,440 little video games share with your 88 00:02:57,840 --> 00:03:01,920 family and friends uh 89 00:02:59,440 --> 00:03:03,599 let's jump in and get started so 90 00:03:01,920 --> 00:03:06,080 we'll see how it goes 91 00:03:03,599 --> 00:03:07,440 here's gotto open on my uh my macos 92 00:03:06,080 --> 00:03:10,080 device 93 00:03:07,440 --> 00:03:12,080 godo runs on pretty much anything linux 94 00:03:10,080 --> 00:03:13,840 macos windows 95 00:03:12,080 --> 00:03:14,959 you can uh see it running in the dock 96 00:03:13,840 --> 00:03:16,239 there it's got this cute little robot 97 00:03:14,959 --> 00:03:17,440 icon 98 00:03:16,239 --> 00:03:18,959 so 99 00:03:17,440 --> 00:03:20,959 in godo 100 00:03:18,959 --> 00:03:22,480 godo is actually written in godo so the 101 00:03:20,959 --> 00:03:24,640 game engine itself that you're using to 102 00:03:22,480 --> 00:03:26,239 write your game is actually built using 103 00:03:24,640 --> 00:03:27,519 godo which is a pretty cool thing and 104 00:03:26,239 --> 00:03:29,280 they're pretty cool proof that it's 105 00:03:27,519 --> 00:03:30,319 actually a pretty solid thing 106 00:03:29,280 --> 00:03:33,760 i'm going to click the new project 107 00:03:30,319 --> 00:03:36,400 button to make a brand new project 108 00:03:33,760 --> 00:03:37,440 well hopefully that works 109 00:03:36,400 --> 00:03:39,200 and 110 00:03:37,440 --> 00:03:40,400 and we're going to call it paris and 111 00:03:39,200 --> 00:03:42,560 tim's game 112 00:03:40,400 --> 00:03:45,040 because we designed this uh this game 113 00:03:42,560 --> 00:03:47,440 together with tim nugent my colleague 114 00:03:45,040 --> 00:03:49,519 for using in talks and tutorials 115 00:03:47,440 --> 00:03:51,599 and i'm going to select opengl 3 116 00:03:49,519 --> 00:03:55,519 and create an edit and it's going to 117 00:03:51,599 --> 00:03:55,519 make a brand new project in gotto 118 00:03:55,680 --> 00:03:58,640 and i'm just going to maximize godot 119 00:03:57,040 --> 00:04:00,640 there 120 00:03:58,640 --> 00:04:03,439 so this is gotto got it looks like most 121 00:04:00,640 --> 00:04:05,760 3d tools in most game engines it has a a 122 00:04:03,439 --> 00:04:07,840 3d environment for you to navigate in 123 00:04:05,760 --> 00:04:10,159 and move around in it operates on three 124 00:04:07,840 --> 00:04:12,239 different axes x y and z 125 00:04:10,159 --> 00:04:14,799 and you can manipulate the scene using 126 00:04:12,239 --> 00:04:16,400 those axes in the corner there so we're 127 00:04:14,799 --> 00:04:18,479 not going to go into too much detail on 128 00:04:16,400 --> 00:04:20,720 how to navigate in 3d hopefully many of 129 00:04:18,479 --> 00:04:22,720 you have used blender or a similar 3d 130 00:04:20,720 --> 00:04:24,479 tool but if you're not it's not too hard 131 00:04:22,720 --> 00:04:26,000 my only recommendation would be if you 132 00:04:24,479 --> 00:04:27,280 were using a laptop maybe plug in a 133 00:04:26,000 --> 00:04:28,560 mouse if you're not super confident 134 00:04:27,280 --> 00:04:30,080 using the trackpad to do this kind of 135 00:04:28,560 --> 00:04:33,120 thing 136 00:04:30,080 --> 00:04:34,880 so this is our big formless void that we 137 00:04:33,120 --> 00:04:36,160 exist in here in godo 138 00:04:34,880 --> 00:04:39,520 and we're going to turn this formless 139 00:04:36,160 --> 00:04:41,120 void into a video game 140 00:04:39,520 --> 00:04:43,199 to turn this formless void into a video 141 00:04:41,120 --> 00:04:44,560 game uh 142 00:04:43,199 --> 00:04:47,680 it's empty at the moment we're going to 143 00:04:44,560 --> 00:04:50,320 add a node to this scene 144 00:04:47,680 --> 00:04:52,320 uh our root node for the scene is kind 145 00:04:50,320 --> 00:04:54,240 of going to dictate what kind of scene 146 00:04:52,320 --> 00:04:57,600 it is so everything in godot is made up 147 00:04:54,240 --> 00:04:59,360 of scenes with nodes in them 148 00:04:57,600 --> 00:05:03,039 here are the options for the various 149 00:04:59,360 --> 00:05:03,039 kinds of root nodes we can create 150 00:05:04,160 --> 00:05:08,960 we're going to make it spatial 151 00:05:06,479 --> 00:05:11,360 so a spatial node is a basic 3d parent 152 00:05:08,960 --> 00:05:12,880 in gono so everything that is kind of 3d 153 00:05:11,360 --> 00:05:15,039 descends from this spatial mode and 154 00:05:12,880 --> 00:05:17,440 gallo spatula doesn't really do anything 155 00:05:15,039 --> 00:05:19,520 beyond have a a transform 156 00:05:17,440 --> 00:05:22,160 a space a thing that makes it exist in 157 00:05:19,520 --> 00:05:23,680 the space in a certain position 158 00:05:22,160 --> 00:05:25,199 so here is our spatial node it's 159 00:05:23,680 --> 00:05:27,280 currently just called spatial it's very 160 00:05:25,199 --> 00:05:29,199 unexciting 161 00:05:27,280 --> 00:05:30,800 we can add additional nodes below this 162 00:05:29,199 --> 00:05:33,840 spatial node as we desire and we'll be 163 00:05:30,800 --> 00:05:33,840 doing a lot of that today 164 00:05:34,000 --> 00:05:37,199 so 165 00:05:35,039 --> 00:05:41,039 this is our spatial node here in the in 166 00:05:37,199 --> 00:05:43,520 the node list in the node viewer 167 00:05:41,039 --> 00:05:45,680 we're going to add another node 168 00:05:43,520 --> 00:05:47,520 while our spatial node is selected 169 00:05:45,680 --> 00:05:48,880 it's going to be a mesh 170 00:05:47,520 --> 00:05:52,479 instance node 171 00:05:48,880 --> 00:05:53,840 a mesh instance node references a mesh 172 00:05:52,479 --> 00:05:56,080 and lets us have something visible in 173 00:05:53,840 --> 00:05:57,680 the scene so it meshes any kind of 3d 174 00:05:56,080 --> 00:05:59,280 object it could be a primitive 3d object 175 00:05:57,680 --> 00:06:02,319 like a cube or it could be something 176 00:05:59,280 --> 00:06:02,319 you've rendered in blender 177 00:06:03,039 --> 00:06:06,720 so node is the parent of all things in 178 00:06:04,800 --> 00:06:07,919 godo and then we're using spatial node 179 00:06:06,720 --> 00:06:10,000 which is below it and then there's this 180 00:06:07,919 --> 00:06:13,039 hierarchy of nodes which dictate how 181 00:06:10,000 --> 00:06:15,120 things work so a mesh instance is 182 00:06:13,039 --> 00:06:17,759 a child of spatial and spatial is a 183 00:06:15,120 --> 00:06:19,199 child of node 184 00:06:17,759 --> 00:06:21,280 so we've now got a smash instance as a 185 00:06:19,199 --> 00:06:23,280 child of our spatial mode 186 00:06:21,280 --> 00:06:24,880 we're going to make a cube so over here 187 00:06:23,280 --> 00:06:26,639 in the inspector while our mesh instance 188 00:06:24,880 --> 00:06:28,240 is selected over on the right side of 189 00:06:26,639 --> 00:06:30,000 the screen 190 00:06:28,240 --> 00:06:31,600 we're going to add an actual mesh so 191 00:06:30,000 --> 00:06:34,880 we're going to click the empty mesh area 192 00:06:31,600 --> 00:06:36,240 i'm going to go new cube mesh 193 00:06:34,880 --> 00:06:38,319 uh if we wanted to we could import an 194 00:06:36,240 --> 00:06:40,160 actual mesh from like blender or one of 195 00:06:38,319 --> 00:06:42,560 the commercial modeling packages here if 196 00:06:40,160 --> 00:06:44,639 we wanted to but uh goto like most game 197 00:06:42,560 --> 00:06:46,880 engines ships with a bunch of primitive 198 00:06:44,639 --> 00:06:48,319 uh you can use 199 00:06:46,880 --> 00:06:50,400 so now is our lovely cube as you can see 200 00:06:48,319 --> 00:06:51,520 that video game is basically done 201 00:06:50,400 --> 00:06:52,960 we're going to go to the materials 202 00:06:51,520 --> 00:06:54,080 section and go 203 00:06:52,960 --> 00:06:57,280 new 204 00:06:54,080 --> 00:06:59,039 spatial material 205 00:06:57,280 --> 00:07:00,319 and we're going to set it to a color 206 00:06:59,039 --> 00:07:01,759 because we want our video game to be 207 00:07:00,319 --> 00:07:06,080 nice and colorful 208 00:07:01,759 --> 00:07:09,520 so uh hmm what color should we make it 209 00:07:06,080 --> 00:07:09,520 maybe yeah orangey 210 00:07:10,160 --> 00:07:13,919 yeah this is a good color so this mesh 211 00:07:12,319 --> 00:07:15,680 cube is going to be our floor for our 212 00:07:13,919 --> 00:07:16,400 video game so our floor is going to be a 213 00:07:15,680 --> 00:07:18,800 nice 214 00:07:16,400 --> 00:07:22,319 egregious orangey brown 215 00:07:18,800 --> 00:07:25,599 kind of color that looks pretty good 216 00:07:22,319 --> 00:07:26,560 so we've got our nice orange cube 217 00:07:25,599 --> 00:07:27,919 so 218 00:07:26,560 --> 00:07:30,080 with our cube made we're going to select 219 00:07:27,919 --> 00:07:31,120 the mesh instance over in our inspector 220 00:07:30,080 --> 00:07:32,639 again 221 00:07:31,120 --> 00:07:35,360 and we're going to click the little mesh 222 00:07:32,639 --> 00:07:36,560 button in the top of the screen 223 00:07:35,360 --> 00:07:39,440 this button 224 00:07:36,560 --> 00:07:40,720 allows us to create a static body for 225 00:07:39,440 --> 00:07:43,599 the mesh 226 00:07:40,720 --> 00:07:45,440 so this body will allow the mesh to 227 00:07:43,599 --> 00:07:46,800 collide with things in the world 228 00:07:45,440 --> 00:07:48,400 currently it's just a picture of a cube 229 00:07:46,800 --> 00:07:51,360 and by clicking this button we give it a 230 00:07:48,400 --> 00:07:52,879 static body which allows it to collide 231 00:07:51,360 --> 00:07:54,960 with things in the physics engine that 232 00:07:52,879 --> 00:07:57,039 godo ships with 233 00:07:54,960 --> 00:08:00,000 so 234 00:07:57,039 --> 00:08:01,599 video games uh 235 00:08:00,000 --> 00:08:03,199 often have really high resolution 236 00:08:01,599 --> 00:08:04,879 complex meshes 237 00:08:03,199 --> 00:08:06,639 uh so 238 00:08:04,879 --> 00:08:08,400 you need to create a 239 00:08:06,639 --> 00:08:09,840 fancy collision body to map to it 240 00:08:08,400 --> 00:08:11,039 because you can't use the mesh itself as 241 00:08:09,840 --> 00:08:13,280 the collision body for performance 242 00:08:11,039 --> 00:08:15,120 reasons in older video games you'd often 243 00:08:13,280 --> 00:08:16,639 use the mesh itself as the collider 244 00:08:15,120 --> 00:08:18,720 these days you kind of want to make a 245 00:08:16,639 --> 00:08:19,919 simplified mesh that goes around it to 246 00:08:18,720 --> 00:08:21,599 serve as the collision body you 247 00:08:19,919 --> 00:08:22,639 technically don't have to do that 248 00:08:21,599 --> 00:08:24,080 because we're doing it with cubes we 249 00:08:22,639 --> 00:08:25,440 could get away with just using the cube 250 00:08:24,080 --> 00:08:26,879 as the collision body 251 00:08:25,440 --> 00:08:28,080 but good practice in video game 252 00:08:26,879 --> 00:08:29,520 development is to create a collision 253 00:08:28,080 --> 00:08:30,800 shape that is a simplified version of 254 00:08:29,520 --> 00:08:32,080 the thing you're actually using in this 255 00:08:30,800 --> 00:08:34,959 case the simplified version will just be 256 00:08:32,080 --> 00:08:36,880 another copy of a cube but uh using that 257 00:08:34,959 --> 00:08:39,200 create mesh button means you're doing it 258 00:08:36,880 --> 00:08:42,640 properly 259 00:08:39,200 --> 00:08:44,080 so a static body in godot is a thing 260 00:08:42,640 --> 00:08:45,760 that exists in the phoenix engine but 261 00:08:44,080 --> 00:08:47,440 doesn't move or is at least strongly 262 00:08:45,760 --> 00:08:48,880 discouraged from moving so there's a 263 00:08:47,440 --> 00:08:50,000 different type of body with a collider 264 00:08:48,880 --> 00:08:53,200 you would make if you wanted it to move 265 00:08:50,000 --> 00:08:53,200 and you'll see that a bit later 266 00:08:53,519 --> 00:08:56,959 so i'm going to select the mesh and push 267 00:08:55,040 --> 00:08:58,000 the r button which switches to scaling 268 00:08:56,959 --> 00:08:59,920 mode and you can see the different tools 269 00:08:58,000 --> 00:09:01,200 we can use here so i push the r button 270 00:08:59,920 --> 00:09:03,519 on the keyboard and i'm going to squish 271 00:09:01,200 --> 00:09:04,959 the cube a little bit to make a floor 272 00:09:03,519 --> 00:09:06,320 this is just changing the transform of 273 00:09:04,959 --> 00:09:08,000 the cube 274 00:09:06,320 --> 00:09:10,320 it doesn't mean i have to do anything 275 00:09:08,000 --> 00:09:11,600 precisely uh i could just make a floor 276 00:09:10,320 --> 00:09:13,040 basically so i could also use the 277 00:09:11,600 --> 00:09:15,680 transform inspector to fiddle with it 278 00:09:13,040 --> 00:09:17,600 here so i'm going to make it bigger 10 279 00:09:15,680 --> 00:09:19,680 and i'm going to make it half high and 280 00:09:17,600 --> 00:09:22,640 i'm going to make it 10 again 281 00:09:19,680 --> 00:09:24,640 so now we've got a nice big flat floor 282 00:09:22,640 --> 00:09:26,880 it's our orange 283 00:09:24,640 --> 00:09:29,200 so most video game engines have kind of 284 00:09:26,880 --> 00:09:31,120 settled on this approach where you have 285 00:09:29,200 --> 00:09:34,720 objects with parameters attached to them 286 00:09:31,120 --> 00:09:36,880 uh commercial alike unity unreal goto 287 00:09:34,720 --> 00:09:39,279 game maker all of them have this kind of 288 00:09:36,880 --> 00:09:40,399 component based architecture 289 00:09:39,279 --> 00:09:41,360 that they use 290 00:09:40,399 --> 00:09:43,680 to 291 00:09:41,360 --> 00:09:46,080 give things behaviors and parameters so 292 00:09:43,680 --> 00:09:47,680 you attach things to things and some of 293 00:09:46,080 --> 00:09:50,000 those things have parameters in godo's 294 00:09:47,680 --> 00:09:51,440 case you have nodes and you have 295 00:09:50,000 --> 00:09:53,200 components attached to those which give 296 00:09:51,440 --> 00:09:54,080 you properties 297 00:09:53,200 --> 00:09:55,600 uh 298 00:09:54,080 --> 00:09:56,720 yeah it's very common this is not just a 299 00:09:55,600 --> 00:09:58,080 gun i think this is a generic game 300 00:09:56,720 --> 00:09:59,839 development thing 301 00:09:58,080 --> 00:10:00,959 i've just renamed the spatial mode to 302 00:09:59,839 --> 00:10:02,399 floor 303 00:10:00,959 --> 00:10:04,079 so i've right clicked on it and gone 304 00:10:02,399 --> 00:10:05,279 rename and call it floor because it's a 305 00:10:04,079 --> 00:10:08,079 floor 306 00:10:05,279 --> 00:10:09,680 so our scene is currently unsaved 307 00:10:08,079 --> 00:10:10,800 we need to save it so to save it i'm 308 00:10:09,680 --> 00:10:13,040 going to push command s on mac or 309 00:10:10,800 --> 00:10:14,880 control this on linux or windows 310 00:10:13,040 --> 00:10:16,399 floor.tscn is good i'm going to just 311 00:10:14,880 --> 00:10:18,560 save it so now we've got a floor scene 312 00:10:16,399 --> 00:10:20,160 it's saved you'll see down here in the 313 00:10:18,560 --> 00:10:22,240 file system inspector we have a copy of 314 00:10:20,160 --> 00:10:24,160 that floor scene available to us now 315 00:10:22,240 --> 00:10:25,360 that's everything for the floor 316 00:10:24,160 --> 00:10:26,800 so 317 00:10:25,360 --> 00:10:28,399 godo 318 00:10:26,800 --> 00:10:30,240 actually 319 00:10:28,399 --> 00:10:31,680 does something quite interesting and 320 00:10:30,240 --> 00:10:34,160 many other game engines now inspired by 321 00:10:31,680 --> 00:10:35,760 godown are doing as well uh goto builds 322 00:10:34,160 --> 00:10:37,600 everything up out of scenes 323 00:10:35,760 --> 00:10:39,360 so you can actually nest scenes within 324 00:10:37,600 --> 00:10:40,560 each other and we'll see how that works 325 00:10:39,360 --> 00:10:42,160 later on 326 00:10:40,560 --> 00:10:43,440 uh you might have like a player scene 327 00:10:42,160 --> 00:10:45,040 you might have multiple players scene 328 00:10:43,440 --> 00:10:46,880 you could load multiple instances of one 329 00:10:45,040 --> 00:10:49,519 scene to another scene so you kind of 330 00:10:46,880 --> 00:10:50,800 use scenes as this basic object format 331 00:10:49,519 --> 00:10:53,040 which you can then load into other 332 00:10:50,800 --> 00:10:54,720 scenes so you can replicate things and 333 00:10:53,040 --> 00:10:55,760 then only update the original 334 00:10:54,720 --> 00:10:57,120 for 335 00:10:55,760 --> 00:10:59,680 creating it 336 00:10:57,120 --> 00:11:01,680 it's very useful uh godo and unity 337 00:10:59,680 --> 00:11:02,959 really lean on this heavily so speaking 338 00:11:01,680 --> 00:11:04,720 of scenes i'm going to make a new scene 339 00:11:02,959 --> 00:11:05,839 right now with the scene menu and now 340 00:11:04,720 --> 00:11:08,240 we'll end up with an empty scene you'll 341 00:11:05,839 --> 00:11:09,360 see the flaw still is up there 342 00:11:08,240 --> 00:11:10,720 i'm going to do pretty much exactly the 343 00:11:09,360 --> 00:11:12,160 same thing as i did last time and add a 344 00:11:10,720 --> 00:11:13,920 new spatial node 345 00:11:12,160 --> 00:11:15,600 inside that spatial node i will add a 346 00:11:13,920 --> 00:11:17,279 mesh instance 347 00:11:15,600 --> 00:11:19,120 exactly the same as i did last time 348 00:11:17,279 --> 00:11:21,920 inside the mesh instance i will create a 349 00:11:19,120 --> 00:11:24,240 new mesh again another cube 350 00:11:21,920 --> 00:11:26,560 and i will create another material and 351 00:11:24,240 --> 00:11:27,600 set a different color on this mesh and 352 00:11:26,560 --> 00:11:28,720 we'll have to have a think about which 353 00:11:27,600 --> 00:11:30,399 column 354 00:11:28,720 --> 00:11:32,959 maybe yellowy 355 00:11:30,399 --> 00:11:36,240 yellow's good a bit too green there yeah 356 00:11:32,959 --> 00:11:36,240 yellow yellowy 357 00:11:36,720 --> 00:11:39,760 yellow is good that's disgusting yellow 358 00:11:38,640 --> 00:11:41,360 love it 359 00:11:39,760 --> 00:11:42,640 perfect 360 00:11:41,360 --> 00:11:44,399 i'm going to create another tri-mesh 361 00:11:42,640 --> 00:11:45,839 static body for our mesh because it's 362 00:11:44,399 --> 00:11:47,360 also going to be static and i'm also 363 00:11:45,839 --> 00:11:49,360 going to scale it a little bit by 364 00:11:47,360 --> 00:11:50,760 modifying the transform i'm going to 365 00:11:49,360 --> 00:11:52,560 make it uh 366 00:11:50,760 --> 00:11:55,680 0.25 367 00:11:52,560 --> 00:11:58,639 1 and 10. so this is going to be a nice 368 00:11:55,680 --> 00:11:58,639 wall for us to use 369 00:11:59,120 --> 00:12:03,279 so 370 00:11:59,920 --> 00:12:06,079 you'll see we've made a little wall here 371 00:12:03,279 --> 00:12:07,600 i'm going to rename the spatial node to 372 00:12:06,079 --> 00:12:08,560 wall 373 00:12:07,600 --> 00:12:10,160 walls 374 00:12:08,560 --> 00:12:12,399 and i'm going to save that scene so it's 375 00:12:10,160 --> 00:12:15,920 going to be called walls.tscn 376 00:12:12,399 --> 00:12:17,839 now we've got two scenes open 377 00:12:15,920 --> 00:12:19,600 we've made two fantastic scenes a floor 378 00:12:17,839 --> 00:12:21,440 and a walls both egregious disgusting 379 00:12:19,600 --> 00:12:22,480 colors i'm going to make yet another 380 00:12:21,440 --> 00:12:23,600 scene now 381 00:12:22,480 --> 00:12:25,040 and 382 00:12:23,600 --> 00:12:27,200 i'm going to add a spatial node to that 383 00:12:25,040 --> 00:12:29,519 scene 384 00:12:27,200 --> 00:12:31,120 yep spatial node done 385 00:12:29,519 --> 00:12:33,200 i'm going to rename the spatial node to 386 00:12:31,120 --> 00:12:34,880 environment 387 00:12:33,200 --> 00:12:35,760 this uh this scene is going to hold our 388 00:12:34,880 --> 00:12:37,600 level 389 00:12:35,760 --> 00:12:39,360 this is going to hold our world that the 390 00:12:37,600 --> 00:12:42,000 player has adventures in 391 00:12:39,360 --> 00:12:44,560 so i'm going to select the spatial node 392 00:12:42,000 --> 00:12:46,079 and click the link node so the add node 393 00:12:44,560 --> 00:12:48,079 lets you add new fresh nodes to the 394 00:12:46,079 --> 00:12:50,000 scene and the link node lets you bring 395 00:12:48,079 --> 00:12:51,279 in existing scenes so i'm going to click 396 00:12:50,000 --> 00:12:52,800 that link button 397 00:12:51,279 --> 00:12:54,240 and you'll see my two scenes already 398 00:12:52,800 --> 00:12:55,680 saved before 399 00:12:54,240 --> 00:12:57,519 i'm going to click the floor 400 00:12:55,680 --> 00:12:59,040 so now we've linked the floor scene into 401 00:12:57,519 --> 00:13:00,480 our new scene 402 00:12:59,040 --> 00:13:01,839 so anything we modify in the original 403 00:13:00,480 --> 00:13:04,079 floor scene will take effect in this 404 00:13:01,839 --> 00:13:05,680 scene because they're linked 405 00:13:04,079 --> 00:13:07,040 i'm going to now 406 00:13:05,680 --> 00:13:08,959 do the same thing again so i'm going to 407 00:13:07,040 --> 00:13:11,120 select the environment node so it's 408 00:13:08,959 --> 00:13:14,880 going to be a child of the environment 409 00:13:11,120 --> 00:13:16,399 and then i'm going to select walls 410 00:13:14,880 --> 00:13:17,920 so now you'll see my walls are on top of 411 00:13:16,399 --> 00:13:19,279 my floor well actually embedded in it 412 00:13:17,920 --> 00:13:21,200 right now 413 00:13:19,279 --> 00:13:23,440 i'm going to use the move tool w on the 414 00:13:21,200 --> 00:13:25,680 keyboard and i'm going to move the walls 415 00:13:23,440 --> 00:13:26,800 to be you know actual walls i'm going to 416 00:13:25,680 --> 00:13:28,639 move them 417 00:13:26,800 --> 00:13:30,800 over here it's not snapping very nicely 418 00:13:28,639 --> 00:13:32,560 so i'm going to actually turn on snap by 419 00:13:30,800 --> 00:13:34,560 selecting the snap button or pushing y 420 00:13:32,560 --> 00:13:35,839 on my keyboard which will make it snap 421 00:13:34,560 --> 00:13:38,399 you can configure the snap and how it 422 00:13:35,839 --> 00:13:39,680 works so what parameters it snaps to 423 00:13:38,399 --> 00:13:43,040 i'm going to switch the view to the top 424 00:13:39,680 --> 00:13:44,480 so i can see it nicely to align my walls 425 00:13:43,040 --> 00:13:46,320 now i can use snap to place the wall in 426 00:13:44,480 --> 00:13:47,760 the right position 427 00:13:46,320 --> 00:13:49,440 i'm going to select the walls and push 428 00:13:47,760 --> 00:13:52,160 command d on my mac or control d on 429 00:13:49,440 --> 00:13:54,160 linux or windows and duplicate my walls 430 00:13:52,160 --> 00:13:56,000 again these are all linked copies of the 431 00:13:54,160 --> 00:13:58,720 original wall scene so if i went to wall 432 00:13:56,000 --> 00:14:00,399 scene and made it less egregious yellow 433 00:13:58,720 --> 00:14:01,279 it would change all the copies of the 434 00:14:00,399 --> 00:14:03,680 wall 435 00:14:01,279 --> 00:14:05,440 i'm going to duplicate the wall again 436 00:14:03,680 --> 00:14:07,440 so we've got three walls now this is 437 00:14:05,440 --> 00:14:09,360 pretty common in most games you are 438 00:14:07,440 --> 00:14:11,920 duplicate things move around in 3d space 439 00:14:09,360 --> 00:14:14,000 duplicate things so on and so on so i 440 00:14:11,920 --> 00:14:15,279 need to rotate it so with the wall i 441 00:14:14,000 --> 00:14:17,199 need to rotate selected i'm going to go 442 00:14:15,279 --> 00:14:20,160 to the transform inspector and going to 443 00:14:17,199 --> 00:14:21,680 rotate it 90 degrees on the y axis 444 00:14:20,160 --> 00:14:24,079 so it's flipped around exactly how we 445 00:14:21,680 --> 00:14:25,680 need it then i'm going to move it 446 00:14:24,079 --> 00:14:27,120 and duplicate it again 447 00:14:25,680 --> 00:14:30,800 and put it down at the bottom so now we 448 00:14:27,120 --> 00:14:31,760 have four walls on our scene 449 00:14:30,800 --> 00:14:33,519 i could fiddle with the snapping a 450 00:14:31,760 --> 00:14:35,440 little bit to make it more precise 451 00:14:33,519 --> 00:14:37,279 but uh this is how you do that i haven't 452 00:14:35,440 --> 00:14:38,880 got the energy to do that right now 453 00:14:37,279 --> 00:14:40,320 you know so i can make it 454 00:14:38,880 --> 00:14:41,519 0.5 on i guess i'm not as lazy as i 455 00:14:40,320 --> 00:14:43,120 thought it was 456 00:14:41,519 --> 00:14:45,600 so now i can snap a little bit better 457 00:14:43,120 --> 00:14:46,720 nice nice and precise 458 00:14:45,600 --> 00:14:47,519 it looks good how it was i'm gonna leave 459 00:14:46,720 --> 00:14:48,560 it 460 00:14:47,519 --> 00:14:50,639 now i'm gonna save this as 461 00:14:48,560 --> 00:14:52,320 environment.tcn so command s or control 462 00:14:50,639 --> 00:14:53,600 s and saving 463 00:14:52,320 --> 00:14:56,399 now i've saved the scene we've got this 464 00:14:53,600 --> 00:14:58,639 beautiful scene up and running 465 00:14:56,399 --> 00:14:59,760 look at that it's beautiful our game is 466 00:14:58,639 --> 00:15:01,199 almost done 467 00:14:59,760 --> 00:15:02,880 so obviously i need to move the walls up 468 00:15:01,199 --> 00:15:03,839 a little bit so i'll just slide them up 469 00:15:02,880 --> 00:15:05,519 a little bit 470 00:15:03,839 --> 00:15:07,680 they're not quite in the right position 471 00:15:05,519 --> 00:15:09,920 i want them to be in so i'll move them 472 00:15:07,680 --> 00:15:11,279 all up while the snap tool is still on 473 00:15:09,920 --> 00:15:13,600 this one 474 00:15:11,279 --> 00:15:15,120 and this one 475 00:15:13,600 --> 00:15:16,560 that looks great 476 00:15:15,120 --> 00:15:18,560 now they're much more wallish than they 477 00:15:16,560 --> 00:15:22,160 used to be beautiful 478 00:15:18,560 --> 00:15:23,760 so also hit command s to save it 479 00:15:22,160 --> 00:15:27,199 beautiful floor it's great we're nearly 480 00:15:23,760 --> 00:15:28,480 done we're not actually done no okay so 481 00:15:27,199 --> 00:15:29,759 now i'm going to rename the floor to 482 00:15:28,480 --> 00:15:30,560 lower floor 483 00:15:29,759 --> 00:15:31,920 because we're going to have an upper 484 00:15:30,560 --> 00:15:33,680 floor in a minute as well and we don't 485 00:15:31,920 --> 00:15:35,120 want to get confused i can't put spaces 486 00:15:33,680 --> 00:15:37,440 in and i am just used to not having 487 00:15:35,120 --> 00:15:38,639 spaces in files 488 00:15:37,440 --> 00:15:41,639 i'm going to link another instance of 489 00:15:38,639 --> 00:15:41,639 floor 490 00:15:42,399 --> 00:15:45,759 well oops no i'm going to link another 491 00:15:43,600 --> 00:15:47,279 instance of the floor scene sorry 492 00:15:45,759 --> 00:15:49,279 there we go i don't want to nest myself 493 00:15:47,279 --> 00:15:50,399 in myself there so now i have two floors 494 00:15:49,279 --> 00:15:51,759 they're exactly in the same place right 495 00:15:50,399 --> 00:15:53,920 now so i'm going to move one of them up 496 00:15:51,759 --> 00:15:55,519 a little bit and put it over here so we 497 00:15:53,920 --> 00:15:57,680 have an upper floor and a lower floor 498 00:15:55,519 --> 00:15:58,880 isn't that fantastic look at them 499 00:15:57,680 --> 00:16:00,880 i'm going to rename it so it's upper 500 00:15:58,880 --> 00:16:02,399 floor and i don't confuse myself 501 00:16:00,880 --> 00:16:04,399 again you can have spaces i'm just old 502 00:16:02,399 --> 00:16:07,199 school 503 00:16:04,399 --> 00:16:09,279 so with our two floors in place 504 00:16:07,199 --> 00:16:10,560 uh we can 505 00:16:09,279 --> 00:16:11,920 move on 506 00:16:10,560 --> 00:16:13,360 so 507 00:16:11,920 --> 00:16:14,480 two floors what else do you think we 508 00:16:13,360 --> 00:16:17,839 need well 509 00:16:14,480 --> 00:16:19,440 we might need a uh 510 00:16:17,839 --> 00:16:21,680 an additional 511 00:16:19,440 --> 00:16:22,880 way to get between the two floors i'm 512 00:16:21,680 --> 00:16:24,160 not going to put any walls on the upper 513 00:16:22,880 --> 00:16:25,360 floor i'm actually going to make a brand 514 00:16:24,160 --> 00:16:26,399 new scene again 515 00:16:25,360 --> 00:16:27,920 and 516 00:16:26,399 --> 00:16:31,519 repeat the process that we've done so 517 00:16:27,920 --> 00:16:33,199 far add a spatial node uh you know add a 518 00:16:31,519 --> 00:16:34,320 mesh instance 519 00:16:33,199 --> 00:16:35,360 uh first i'm going to run this ramp 520 00:16:34,320 --> 00:16:39,279 actually 521 00:16:35,360 --> 00:16:41,120 now i'm going to add the mesh instance 522 00:16:39,279 --> 00:16:42,320 and with my mesh instance i'm going to 523 00:16:41,120 --> 00:16:44,079 create a 524 00:16:42,320 --> 00:16:47,199 oops i didn't create a mesh i'm going to 525 00:16:44,079 --> 00:16:49,600 create a mesh on this new mesh instance 526 00:16:47,199 --> 00:16:50,399 so we actually have something 527 00:16:49,600 --> 00:16:51,920 visible 528 00:16:50,399 --> 00:16:53,279 so on our mesh instance i'm going to 529 00:16:51,920 --> 00:16:54,720 select the mesh instance and then like a 530 00:16:53,279 --> 00:16:55,839 second ago i'm going to create a new 531 00:16:54,720 --> 00:16:58,959 cube mesh 532 00:16:55,839 --> 00:17:01,440 and pick a new egregious color so maybe 533 00:16:58,959 --> 00:17:03,120 like another green yellow egregious 534 00:17:01,440 --> 00:17:05,520 i don't know maybe 535 00:17:03,120 --> 00:17:06,640 ooh green yeah maybe nice and green that 536 00:17:05,520 --> 00:17:07,679 looks good 537 00:17:06,640 --> 00:17:10,240 okay 538 00:17:07,679 --> 00:17:12,640 the green really screams ramp to me 539 00:17:10,240 --> 00:17:15,039 so big ramp energy so i'm going to 540 00:17:12,640 --> 00:17:17,439 create my static clutter again 541 00:17:15,039 --> 00:17:19,439 and modify the transform of this mesh to 542 00:17:17,439 --> 00:17:23,039 make it more ramp like 543 00:17:19,439 --> 00:17:25,000 so maybe uh 1.44 544 00:17:23,039 --> 00:17:27,760 0.1 and 545 00:17:25,000 --> 00:17:28,880 5.47 yeah i think that's good that looks 546 00:17:27,760 --> 00:17:32,000 like around to me i totally did not 547 00:17:28,880 --> 00:17:33,039 prepare those numbers in advance 548 00:17:32,000 --> 00:17:35,440 that's beautiful i'm going to save that 549 00:17:33,039 --> 00:17:37,039 scene as ramp.tscn 550 00:17:35,440 --> 00:17:38,240 done beautiful 551 00:17:37,039 --> 00:17:40,320 back in our environment so i'll switch 552 00:17:38,240 --> 00:17:42,640 the tab at the top there 553 00:17:40,320 --> 00:17:44,799 i'm going to uh link in the ramp 554 00:17:42,640 --> 00:17:47,520 so add the node via the link 555 00:17:44,799 --> 00:17:48,240 button has a child of environment 556 00:17:47,520 --> 00:17:50,080 so 557 00:17:48,240 --> 00:17:53,280 we're going to select that link button 558 00:17:50,080 --> 00:17:54,559 and we're going to choose ramp.tscn 559 00:17:53,280 --> 00:17:56,000 and with the ramp in the scene you'll 560 00:17:54,559 --> 00:17:57,600 see it's embedded in the floor currently 561 00:17:56,000 --> 00:17:58,640 so we're going to move it up a little 562 00:17:57,600 --> 00:18:01,120 bit 563 00:17:58,640 --> 00:18:01,919 there it is it is our facing the wrong 564 00:18:01,120 --> 00:18:03,760 way 565 00:18:01,919 --> 00:18:05,760 but we'll fix it 566 00:18:03,760 --> 00:18:07,120 in a moment 567 00:18:05,760 --> 00:18:08,640 we control the universe so it doesn't 568 00:18:07,120 --> 00:18:10,080 really matter where anything goes so 569 00:18:08,640 --> 00:18:12,640 we'll hit the rotation button and then 570 00:18:10,080 --> 00:18:14,720 we'll use the rotation button to rotate 571 00:18:12,640 --> 00:18:16,240 it a little bit look at that that's 572 00:18:14,720 --> 00:18:18,480 beautiful 573 00:18:16,240 --> 00:18:20,559 rotated and then we'll move it across a 574 00:18:18,480 --> 00:18:22,000 little bit using the move button 575 00:18:20,559 --> 00:18:23,600 and rotate a little bit more so it 576 00:18:22,000 --> 00:18:25,039 actually is a ramp 577 00:18:23,600 --> 00:18:26,880 and we've got a ramp happening there 578 00:18:25,039 --> 00:18:28,960 that's great 579 00:18:26,880 --> 00:18:32,160 that's close enough that's kind of good 580 00:18:28,960 --> 00:18:34,799 i think yeah it looks nice to me 581 00:18:32,160 --> 00:18:36,400 i'm going to save that just so it's uh 582 00:18:34,799 --> 00:18:37,600 preserved 583 00:18:36,400 --> 00:18:38,640 we might clean that up a bit in the 584 00:18:37,600 --> 00:18:40,080 future 585 00:18:38,640 --> 00:18:41,200 but right now 586 00:18:40,080 --> 00:18:44,000 our game is almost there but we're 587 00:18:41,200 --> 00:18:46,240 missing one crucial thing a player 588 00:18:44,000 --> 00:18:49,280 so i'm going to make a new scene 589 00:18:46,240 --> 00:18:50,720 the scene is going to be our player 590 00:18:49,280 --> 00:18:51,919 we could have put all of this in one 591 00:18:50,720 --> 00:18:53,200 scene and made all these things out of 592 00:18:51,919 --> 00:18:55,280 nodes but then it wouldn't be following 593 00:18:53,200 --> 00:18:56,799 a nice reusable game architecture 594 00:18:55,280 --> 00:18:58,320 because when you're building video games 595 00:18:56,799 --> 00:19:00,000 it makes sense to make things out of 596 00:18:58,320 --> 00:19:02,080 composable pieces so you can reuse them 597 00:19:00,000 --> 00:19:03,440 as you need in a multiplayer game you 598 00:19:02,080 --> 00:19:04,960 might have a player scene that is 599 00:19:03,440 --> 00:19:06,720 instantiated multiple times and 600 00:19:04,960 --> 00:19:08,240 connected to different inputs some over 601 00:19:06,720 --> 00:19:09,840 the network for example 602 00:19:08,240 --> 00:19:11,600 and by doing it like this even when 603 00:19:09,840 --> 00:19:13,760 you're making a silly little sample game 604 00:19:11,600 --> 00:19:16,160 uh it helps you keep things 605 00:19:13,760 --> 00:19:17,760 reusable so we're going to create a 606 00:19:16,160 --> 00:19:19,760 kinematic body 607 00:19:17,760 --> 00:19:21,600 kinematic is a fancy word for it moves 608 00:19:19,760 --> 00:19:24,400 so unlike our static body the kinematic 609 00:19:21,600 --> 00:19:26,960 body can actually move around 610 00:19:24,400 --> 00:19:29,120 so we need a mesh as well 611 00:19:26,960 --> 00:19:30,400 so below our kinematic body 612 00:19:29,120 --> 00:19:31,360 we're going to have a mesh it's not 613 00:19:30,400 --> 00:19:32,400 going to be a cube this time we're going 614 00:19:31,360 --> 00:19:34,799 to make a capsule because the 615 00:19:32,400 --> 00:19:37,360 traditional prototyping 616 00:19:34,799 --> 00:19:38,880 mesh for video game is a capsule 617 00:19:37,360 --> 00:19:40,480 prototyping is always a capsule i'm 618 00:19:38,880 --> 00:19:41,600 gonna pick a nice egregious color for 619 00:19:40,480 --> 00:19:44,640 our player 620 00:19:41,600 --> 00:19:46,000 maybe bluey blue yeah i think blue today 621 00:19:44,640 --> 00:19:48,640 for our player 622 00:19:46,000 --> 00:19:50,840 that that says player to me 623 00:19:48,640 --> 00:19:54,080 nice blue player 624 00:19:50,840 --> 00:19:56,240 cube we're not going to rotate it up uh 625 00:19:54,080 --> 00:19:58,000 we'll rotate it up later 626 00:19:56,240 --> 00:20:00,080 so we're going to click on mesh 627 00:19:58,000 --> 00:20:02,960 uh click our kinematic body and click 628 00:20:00,080 --> 00:20:04,559 collision shape 629 00:20:02,960 --> 00:20:08,159 this allows us to 630 00:20:04,559 --> 00:20:09,679 represent this in the physics engine 631 00:20:08,159 --> 00:20:12,000 but this means it can move as well it's 632 00:20:09,679 --> 00:20:14,640 not a static thing 633 00:20:12,000 --> 00:20:17,520 our collision shape 634 00:20:14,640 --> 00:20:19,919 must have a shape attached to it so with 635 00:20:17,520 --> 00:20:22,480 our collision shape selected we need to 636 00:20:19,919 --> 00:20:25,919 go over to the inspector on the right 637 00:20:22,480 --> 00:20:28,000 and allocate a shape to it 638 00:20:25,919 --> 00:20:29,360 so 639 00:20:28,000 --> 00:20:30,880 our collision has a little error on it 640 00:20:29,360 --> 00:20:33,039 that's because it doesn't have a shape 641 00:20:30,880 --> 00:20:34,720 assigned to it so 642 00:20:33,039 --> 00:20:35,679 in the inspector we're going to go 643 00:20:34,720 --> 00:20:37,280 across 644 00:20:35,679 --> 00:20:38,880 and give it a shape 645 00:20:37,280 --> 00:20:40,240 and surprising nobody it's going to be a 646 00:20:38,880 --> 00:20:41,840 capsule 647 00:20:40,240 --> 00:20:43,039 so this is the uh the thing that's 648 00:20:41,840 --> 00:20:45,280 actually represented in the physics 649 00:20:43,039 --> 00:20:46,799 engine for this shape and coincidentally 650 00:20:45,280 --> 00:20:48,720 it's also a capsule because the capsule 651 00:20:46,799 --> 00:20:50,159 just needs a capsule collider 652 00:20:48,720 --> 00:20:51,840 but unlike the other static stuff we 653 00:20:50,159 --> 00:20:53,600 created because this is kinematic with a 654 00:20:51,840 --> 00:20:56,880 collision shape it can move because it's 655 00:20:53,600 --> 00:20:56,880 helpful when your player can move 656 00:20:58,080 --> 00:21:04,000 with that done 657 00:21:00,559 --> 00:21:05,520 we are going to save our scene and 658 00:21:04,000 --> 00:21:07,679 continue 659 00:21:05,520 --> 00:21:10,080 uh player collision bodies in video 660 00:21:07,679 --> 00:21:12,400 games actually often 661 00:21:10,080 --> 00:21:13,520 cube capsules even if the player is some 662 00:21:12,400 --> 00:21:14,720 sort of complex thing just because it 663 00:21:13,520 --> 00:21:16,000 makes it easier to calculate what's 664 00:21:14,720 --> 00:21:17,760 going on with the environment and keep 665 00:21:16,000 --> 00:21:19,440 keep things simple 666 00:21:17,760 --> 00:21:21,679 big fancy games obviously do other 667 00:21:19,440 --> 00:21:22,880 things but simple video games are often 668 00:21:21,679 --> 00:21:24,320 just capsules so we're going to save our 669 00:21:22,880 --> 00:21:26,000 player scene there 670 00:21:24,320 --> 00:21:28,640 and rename the kinematic body to player 671 00:21:26,000 --> 00:21:30,080 and then save it again 672 00:21:28,640 --> 00:21:31,840 that's it for the player scene so we'll 673 00:21:30,080 --> 00:21:32,799 go back to the environment scene and i 674 00:21:31,840 --> 00:21:34,799 bet you can guess what we're going to do 675 00:21:32,799 --> 00:21:37,600 we're going to link the player scene as 676 00:21:34,799 --> 00:21:40,240 a child of environment 677 00:21:37,600 --> 00:21:42,400 now our little tic-tac-man is in here 678 00:21:40,240 --> 00:21:43,679 man woman tic-tac creature not sure why 679 00:21:42,400 --> 00:21:45,280 a tic-tac has a gender it doesn't need 680 00:21:43,679 --> 00:21:47,520 one uh 681 00:21:45,280 --> 00:21:49,120 it's a tic tac 682 00:21:47,520 --> 00:21:51,039 so 683 00:21:49,120 --> 00:21:54,240 it's a it's a it's a little capsule 684 00:21:51,039 --> 00:21:56,080 player i guess it does not have a gender 685 00:21:54,240 --> 00:21:57,760 you will uh you really really end up 686 00:21:56,080 --> 00:21:59,600 loving your your terrible shapes you use 687 00:21:57,760 --> 00:22:01,200 so don't get too attached to them 688 00:21:59,600 --> 00:22:02,799 we're going to rotate so click that 689 00:22:01,200 --> 00:22:03,919 player without it and rotate it so it's 690 00:22:02,799 --> 00:22:06,080 pointing the right way and then use the 691 00:22:03,919 --> 00:22:07,200 move tool to move it up 692 00:22:06,080 --> 00:22:08,000 it doesn't matter that it's above the 693 00:22:07,200 --> 00:22:09,039 ground because we're going to add 694 00:22:08,000 --> 00:22:10,320 gravity 695 00:22:09,039 --> 00:22:11,679 so for now it can just sit there 696 00:22:10,320 --> 00:22:13,919 floating 697 00:22:11,679 --> 00:22:15,200 that's totally fine 698 00:22:13,919 --> 00:22:16,640 so 699 00:22:15,200 --> 00:22:18,320 we're going to make yet another new 700 00:22:16,640 --> 00:22:20,480 scene 701 00:22:18,320 --> 00:22:22,720 we're going to go scene new scene this 702 00:22:20,480 --> 00:22:25,600 scene is very simple 703 00:22:22,720 --> 00:22:27,520 so we're going to create a rigid body 704 00:22:25,600 --> 00:22:29,919 which allows it to move in the physics 705 00:22:27,520 --> 00:22:29,919 system 706 00:22:30,000 --> 00:22:33,200 this is a little bit different because 707 00:22:31,440 --> 00:22:34,880 it needs to move around the scene in a 708 00:22:33,200 --> 00:22:36,080 different way so we'll cover that in a 709 00:22:34,880 --> 00:22:38,880 second we're going to add a mesh 710 00:22:36,080 --> 00:22:41,760 instance to our rigid body 711 00:22:38,880 --> 00:22:43,760 on our mesh we'll add a sphere 712 00:22:41,760 --> 00:22:45,919 and make an egregious color probably red 713 00:22:43,760 --> 00:22:49,600 i think this time 714 00:22:45,919 --> 00:22:49,600 nice egregious red 715 00:22:49,919 --> 00:22:53,360 we'll add a collision shape 716 00:22:52,400 --> 00:22:55,840 because we want this to be able to 717 00:22:53,360 --> 00:22:57,440 collide because it can move 718 00:22:55,840 --> 00:22:58,720 so we'll click our collision shape and 719 00:22:57,440 --> 00:23:01,120 add a sphere 720 00:22:58,720 --> 00:23:02,480 as the shape in the inspector 721 00:23:01,120 --> 00:23:04,080 it's a rigid body that can move in the 722 00:23:02,480 --> 00:23:05,840 physics engine which can move using 723 00:23:04,080 --> 00:23:07,200 impulses it has a mesh instance to show 724 00:23:05,840 --> 00:23:08,320 it's a ball 725 00:23:07,200 --> 00:23:10,320 and it has a collision shape which is 726 00:23:08,320 --> 00:23:12,720 also a ball or sphere and we'll save it 727 00:23:10,320 --> 00:23:14,080 as ball so ball.tscn and we'll rename 728 00:23:12,720 --> 00:23:15,919 the route to ball 729 00:23:14,080 --> 00:23:18,640 so it's just a ball we're going to save 730 00:23:15,919 --> 00:23:19,760 our ball scene back in the environment 731 00:23:18,640 --> 00:23:20,880 you'll know where this is going we're 732 00:23:19,760 --> 00:23:22,880 going to click environment and link the 733 00:23:20,880 --> 00:23:24,480 ball scene in 734 00:23:22,880 --> 00:23:25,679 and then we have a ball 735 00:23:24,480 --> 00:23:28,320 we're going to move the ball up to the 736 00:23:25,679 --> 00:23:28,320 upper platform 737 00:23:28,880 --> 00:23:31,919 so 738 00:23:30,400 --> 00:23:33,600 the center of all these objects is the 739 00:23:31,919 --> 00:23:35,760 same it's zero zero which is why they 740 00:23:33,600 --> 00:23:37,440 always start in the ground 741 00:23:35,760 --> 00:23:38,880 so they always kind of embed themselves 742 00:23:37,440 --> 00:23:40,480 in each other 743 00:23:38,880 --> 00:23:43,360 that's why so i'm just trying to move it 744 00:23:40,480 --> 00:23:44,720 over to the top platform 745 00:23:43,360 --> 00:23:46,880 so sometimes it gets a bit confusing in 746 00:23:44,720 --> 00:23:47,919 3d space so it's easy to use the the top 747 00:23:46,880 --> 00:23:49,600 view 748 00:23:47,919 --> 00:23:51,120 i am using a trackpad as i said at the 749 00:23:49,600 --> 00:23:52,880 beginning this is much easier if you 750 00:23:51,120 --> 00:23:54,240 have a mouse 751 00:23:52,880 --> 00:23:55,360 uh gravity will come to effect at some 752 00:23:54,240 --> 00:23:58,559 point so it doesn't matter that these 753 00:23:55,360 --> 00:24:00,720 things are currently floating 754 00:23:58,559 --> 00:24:02,080 next thing we need to do is make a goal 755 00:24:00,720 --> 00:24:03,679 so the goal of this game will be the 756 00:24:02,080 --> 00:24:04,640 player tic tac has to push the ball into 757 00:24:03,679 --> 00:24:07,279 a goal 758 00:24:04,640 --> 00:24:09,039 again new scene very simple 759 00:24:07,279 --> 00:24:10,880 making another spatial root note because 760 00:24:09,039 --> 00:24:13,039 this goal will not move around the scene 761 00:24:10,880 --> 00:24:14,240 that's the wrong kind of node 762 00:24:13,039 --> 00:24:17,360 i'm a fool 763 00:24:14,240 --> 00:24:19,440 i had a spatial node 764 00:24:17,360 --> 00:24:21,440 we do not need an audio stream player 765 00:24:19,440 --> 00:24:23,840 the spatial will be named goal as a 766 00:24:21,440 --> 00:24:27,039 child of this goal spatial node we're 767 00:24:23,840 --> 00:24:28,400 going to add a mesh instance once again 768 00:24:27,039 --> 00:24:29,440 and uh 769 00:24:28,400 --> 00:24:30,400 so yeah we're going to make a very 770 00:24:29,440 --> 00:24:31,760 simple game where you have to push the 771 00:24:30,400 --> 00:24:34,240 ball into goal into this goal we're 772 00:24:31,760 --> 00:24:36,080 going to call create a cube 773 00:24:34,240 --> 00:24:37,360 what color should this be 774 00:24:36,080 --> 00:24:39,120 this is 775 00:24:37,360 --> 00:24:41,360 very complicated decision making things 776 00:24:39,120 --> 00:24:44,240 certain colors uh let's go 777 00:24:41,360 --> 00:24:44,240 cyan maybe 778 00:24:44,559 --> 00:24:48,400 maybe maybe 779 00:24:46,799 --> 00:24:51,360 it's that's pretty gross that's probably 780 00:24:48,400 --> 00:24:52,640 the nicest color we've used so far today 781 00:24:51,360 --> 00:24:54,400 i'm gonna 782 00:24:52,640 --> 00:24:57,200 rearrange this a little bit and create 783 00:24:54,400 --> 00:24:59,039 the static uh collision body 784 00:24:57,200 --> 00:25:00,559 because it doesn't need to move 785 00:24:59,039 --> 00:25:02,400 and we're going to duplicate goal 1 786 00:25:00,559 --> 00:25:03,840 after renaming it 787 00:25:02,400 --> 00:25:05,039 no i don't duplicate i'm going to scale 788 00:25:03,840 --> 00:25:06,080 it a little bit and then i'll duplicate 789 00:25:05,039 --> 00:25:08,080 it 790 00:25:06,080 --> 00:25:10,000 smush it a bit 791 00:25:08,080 --> 00:25:12,080 smoosh it like that and smoosh it that 792 00:25:10,000 --> 00:25:14,240 way so it's like a pillar 793 00:25:12,080 --> 00:25:15,760 make it really tall 794 00:25:14,240 --> 00:25:17,600 that's good enough now i'm going to 795 00:25:15,760 --> 00:25:19,760 duplicate it and move it over a little 796 00:25:17,600 --> 00:25:21,600 bit with the move tool 797 00:25:19,760 --> 00:25:23,520 that's a goal i recognize that anywhere 798 00:25:21,600 --> 00:25:26,480 it's kind of goal posts really 799 00:25:23,520 --> 00:25:27,919 yeah that's good that's a goal 800 00:25:26,480 --> 00:25:28,880 so i can see someone kicking a football 801 00:25:27,919 --> 00:25:31,600 through that i'll save that as 802 00:25:28,880 --> 00:25:33,440 goals.tscn 803 00:25:31,600 --> 00:25:35,200 and uh i'll return back to my 804 00:25:33,440 --> 00:25:36,640 environment scene and you guessed it 805 00:25:35,200 --> 00:25:38,400 i'll link 806 00:25:36,640 --> 00:25:39,360 the goal scene into the environment 807 00:25:38,400 --> 00:25:42,799 scene 808 00:25:39,360 --> 00:25:44,559 with the link button bring in the goal 809 00:25:42,799 --> 00:25:46,559 amazing 810 00:25:44,559 --> 00:25:48,240 i'll move the goal somewhere maybe at 811 00:25:46,559 --> 00:25:50,559 the upper level i think today 812 00:25:48,240 --> 00:25:53,120 it doesn't really matter where it goes 813 00:25:50,559 --> 00:25:54,240 that's a good spot for it i think 814 00:25:53,120 --> 00:25:56,640 it's good 815 00:25:54,240 --> 00:25:58,559 yeah look at that that's nice goals over 816 00:25:56,640 --> 00:26:00,720 there that's pretty nice our game is 817 00:25:58,559 --> 00:26:02,480 taking shape 818 00:26:00,720 --> 00:26:05,200 amazing 819 00:26:02,480 --> 00:26:07,120 now we need to make 820 00:26:05,200 --> 00:26:09,039 a little pickup because this is a video 821 00:26:07,120 --> 00:26:10,720 game 822 00:26:09,039 --> 00:26:11,919 we'll make a little pickup that maybe 823 00:26:10,720 --> 00:26:13,360 does something if we get time it's a 824 00:26:11,919 --> 00:26:15,279 video game so video games have pickups 825 00:26:13,360 --> 00:26:16,480 it's very traditional again another 826 00:26:15,279 --> 00:26:19,039 scene 827 00:26:16,480 --> 00:26:20,960 we'll add an area so an area is 828 00:26:19,039 --> 00:26:23,440 something that exists to be collided 829 00:26:20,960 --> 00:26:25,039 with it doesn't necessarily have any 830 00:26:23,440 --> 00:26:26,559 visuals it just has an area that can 831 00:26:25,039 --> 00:26:28,799 tell some part of your game that 832 00:26:26,559 --> 00:26:29,600 something else has collided with it 833 00:26:28,799 --> 00:26:31,120 so 834 00:26:29,600 --> 00:26:32,799 it's a really useful kind of spatial 835 00:26:31,120 --> 00:26:34,320 volume that 836 00:26:32,799 --> 00:26:35,679 has a thing inside or doesn't have a 837 00:26:34,320 --> 00:26:36,799 thing inside it but can detect something 838 00:26:35,679 --> 00:26:38,799 being in there 839 00:26:36,799 --> 00:26:39,760 inside our area we will add a mesh 840 00:26:38,799 --> 00:26:40,880 instance because we're going to add a 841 00:26:39,760 --> 00:26:43,600 cube inside it because you know 842 00:26:40,880 --> 00:26:46,400 everything's a cube everything's a cube 843 00:26:43,600 --> 00:26:47,919 we'll uh go create a new color what 844 00:26:46,400 --> 00:26:49,760 color should this be that's the real 845 00:26:47,919 --> 00:26:52,240 question 846 00:26:49,760 --> 00:26:55,360 maybe do we have a dark purple maybe 847 00:26:52,240 --> 00:26:59,039 yeah oh yeah there we go 848 00:26:55,360 --> 00:26:59,039 our pickup is dark purple 849 00:26:59,200 --> 00:27:02,400 we'll add a collision shape to it 850 00:27:00,480 --> 00:27:04,720 because it's a thing that exists in the 851 00:27:02,400 --> 00:27:06,320 world it needs to be collided with 852 00:27:04,720 --> 00:27:07,840 and we'll go over to the shape and add a 853 00:27:06,320 --> 00:27:09,919 cube to our collision shape because the 854 00:27:07,840 --> 00:27:13,440 cube's collider is also a cube 855 00:27:09,919 --> 00:27:16,159 box not cube yep okay 856 00:27:13,440 --> 00:27:16,159 uh yep 857 00:27:17,520 --> 00:27:20,960 okay i've messed up the child there we 858 00:27:19,200 --> 00:27:22,320 go they both should be child of area 859 00:27:20,960 --> 00:27:24,000 rather than a child of each other there 860 00:27:22,320 --> 00:27:26,159 we go 861 00:27:24,000 --> 00:27:28,399 i'm going to rename the area to pick up 862 00:27:26,159 --> 00:27:29,919 and save the whole scene pickup.tscn and 863 00:27:28,399 --> 00:27:30,960 again back in environment i'll add my 864 00:27:29,919 --> 00:27:34,399 pickup 865 00:27:30,960 --> 00:27:37,120 so i'll select an environment and link 866 00:27:34,399 --> 00:27:38,480 in the pickup 867 00:27:37,120 --> 00:27:39,840 so we've got a nice pickup sitting in 868 00:27:38,480 --> 00:27:42,880 our environment now 869 00:27:39,840 --> 00:27:44,720 i'll move it over into the corner maybe 870 00:27:42,880 --> 00:27:46,080 good spot 871 00:27:44,720 --> 00:27:48,240 fantastic 872 00:27:46,080 --> 00:27:49,440 so the goal of our game is to push the 873 00:27:48,240 --> 00:27:50,960 ball through the goal and close the 874 00:27:49,440 --> 00:27:52,720 pickup it's a very complicated video 875 00:27:50,960 --> 00:27:53,919 game it's going to make a lot of money 876 00:27:52,720 --> 00:27:56,000 uh 877 00:27:53,919 --> 00:27:57,360 once we've done that i'll save it so 878 00:27:56,000 --> 00:27:58,559 you'll notice we haven't coded anything 879 00:27:57,360 --> 00:28:00,799 yet so 880 00:27:58,559 --> 00:28:02,320 it's probably time to code something if 881 00:28:00,799 --> 00:28:05,039 you run the game right now it will do 882 00:28:02,320 --> 00:28:06,159 absolutely nothing 883 00:28:05,039 --> 00:28:07,760 so 884 00:28:06,159 --> 00:28:09,120 you'll see that is running uh paris and 885 00:28:07,760 --> 00:28:10,799 tim's game thanks tim for helping me 886 00:28:09,120 --> 00:28:11,840 build this game originally 887 00:28:10,799 --> 00:28:13,520 we're gonna add a script now to make it 888 00:28:11,840 --> 00:28:15,039 actually do something 889 00:28:13,520 --> 00:28:16,480 i'm gonna click the player 890 00:28:15,039 --> 00:28:18,080 i'm going to right click on it and go 891 00:28:16,480 --> 00:28:19,039 attach script 892 00:28:18,080 --> 00:28:20,480 and it's going to ask me what sort of 893 00:28:19,039 --> 00:28:23,360 script i want i'm going to say i would 894 00:28:20,480 --> 00:28:23,360 like a gd script 895 00:28:23,679 --> 00:28:27,039 i've got to support c sharp gd script 896 00:28:25,679 --> 00:28:28,320 it's kind of native scripting and visual 897 00:28:27,039 --> 00:28:30,159 scripting which is kind of a block based 898 00:28:28,320 --> 00:28:32,480 one today we're going to use gd script 899 00:28:30,159 --> 00:28:34,399 which is a python inspired syntax but is 900 00:28:32,480 --> 00:28:35,600 not python 901 00:28:34,399 --> 00:28:36,960 it's a it's a really good little 902 00:28:35,600 --> 00:28:37,919 language 903 00:28:36,960 --> 00:28:39,360 it's going to ask us what to call it 904 00:28:37,919 --> 00:28:40,480 we're going to leave it by the default 905 00:28:39,360 --> 00:28:41,840 we're going to click create and it's 906 00:28:40,480 --> 00:28:43,679 going to open up the inbuilt editor you 907 00:28:41,840 --> 00:28:46,240 can use vs code or any other editor you 908 00:28:43,679 --> 00:28:49,600 like but goto has a competent perfectly 909 00:28:46,240 --> 00:28:51,039 communal in inbuilt editor 910 00:28:49,600 --> 00:28:52,159 we're going to gloss over this a little 911 00:28:51,039 --> 00:28:53,760 bit to be quick but we're going to get 912 00:28:52,159 --> 00:28:55,039 it done so we're going to create a 913 00:28:53,760 --> 00:28:57,039 variable 914 00:28:55,039 --> 00:28:58,720 with the var keyword 915 00:28:57,039 --> 00:29:00,159 we're going to call it move speed we're 916 00:28:58,720 --> 00:29:02,399 going to set it to 500 completely 917 00:29:00,159 --> 00:29:03,760 arbitrarily 918 00:29:02,399 --> 00:29:05,360 programming is about making numbers up 919 00:29:03,760 --> 00:29:07,440 as we know and video game programming is 920 00:29:05,360 --> 00:29:08,320 doubly about making numbers up 921 00:29:07,440 --> 00:29:10,559 we're going to create a direction 922 00:29:08,320 --> 00:29:14,480 variable which is a vector3 which is a 923 00:29:10,559 --> 00:29:14,480 vector with you know x y and z 924 00:29:15,279 --> 00:29:18,640 so once we've got our move speed and our 925 00:29:17,520 --> 00:29:21,120 direction 926 00:29:18,640 --> 00:29:22,880 we're going to continue going on here uh 927 00:29:21,120 --> 00:29:24,640 vector three if you're not used to it is 928 00:29:22,880 --> 00:29:27,600 just it stores three elements so for 929 00:29:24,640 --> 00:29:29,520 people are confused by that it has x y 930 00:29:27,600 --> 00:29:30,720 and z or whatever you would like to it's 931 00:29:29,520 --> 00:29:32,640 got three components well we'll use it 932 00:29:30,720 --> 00:29:34,159 as an x y and z 933 00:29:32,640 --> 00:29:36,480 it represents a direction uh we 934 00:29:34,159 --> 00:29:38,080 obviously need gravity as well 935 00:29:36,480 --> 00:29:39,039 so gravity in our little world is going 936 00:29:38,080 --> 00:29:40,960 to be 937 00:29:39,039 --> 00:29:42,960 9.8 i'm not sure where i got that from 938 00:29:40,960 --> 00:29:45,279 but uh obviously has no relationship to 939 00:29:42,960 --> 00:29:47,520 the real world but we'll see how it goes 940 00:29:45,279 --> 00:29:49,440 also velocity uh velocity is important 941 00:29:47,520 --> 00:29:51,279 in 3d space so our velocity is also 942 00:29:49,440 --> 00:29:52,799 going to be a vector3 943 00:29:51,279 --> 00:29:54,880 and uh 944 00:29:52,799 --> 00:29:56,960 that's all we need uh we're going to 945 00:29:54,880 --> 00:29:57,760 ignore ready so that doesn't really do 946 00:29:56,960 --> 00:29:59,360 anything 947 00:29:57,760 --> 00:30:00,320 uh ready it's called when a node enters 948 00:29:59,360 --> 00:30:02,159 the scene in godot we don't need to do 949 00:30:00,320 --> 00:30:03,600 anything special right now 950 00:30:02,159 --> 00:30:05,120 i'm going to create a new function 951 00:30:03,600 --> 00:30:07,120 called physics process which is the 952 00:30:05,120 --> 00:30:08,720 thing called every physics tick 953 00:30:07,120 --> 00:30:10,320 so goto has a bunch of predefined 954 00:30:08,720 --> 00:30:11,600 functions we can use to manipulate our 955 00:30:10,320 --> 00:30:13,360 game world 956 00:30:11,600 --> 00:30:14,720 they'll start with underscore 957 00:30:13,360 --> 00:30:15,919 so anything you make starts with no 958 00:30:14,720 --> 00:30:17,679 underscore anything that got a splice 959 00:30:15,919 --> 00:30:19,120 starts to underscore we're gonna set our 960 00:30:17,679 --> 00:30:22,399 direction to 961 00:30:19,120 --> 00:30:23,520 nothing zero vector three zero zero zero 962 00:30:22,399 --> 00:30:24,799 so we're trying to get you excited about 963 00:30:23,520 --> 00:30:26,720 gotta rather than teach you goto so i'm 964 00:30:24,799 --> 00:30:28,640 gonna gloss over this a little bit 965 00:30:26,720 --> 00:30:30,480 physics process gets kicked called every 966 00:30:28,640 --> 00:30:32,880 time the physics tick happens with the 967 00:30:30,480 --> 00:30:34,080 delta which is the time since last tick 968 00:30:32,880 --> 00:30:35,600 so the reason that might be different is 969 00:30:34,080 --> 00:30:37,840 the frame rate might be different to the 970 00:30:35,600 --> 00:30:39,919 physics tick so this lets us account for 971 00:30:37,840 --> 00:30:41,679 the difference 972 00:30:39,919 --> 00:30:43,760 so if input 973 00:30:41,679 --> 00:30:45,360 is action pressed so we're going to 974 00:30:43,760 --> 00:30:47,360 check if 975 00:30:45,360 --> 00:30:49,200 a certain action in the action table ui 976 00:30:47,360 --> 00:30:50,880 left which is whatever key we've mapped 977 00:30:49,200 --> 00:30:52,240 to left using god as action table and 978 00:30:50,880 --> 00:30:54,080 i'll show you where that's set in action 979 00:30:52,240 --> 00:30:56,320 in a second goto has a really powerful 980 00:30:54,080 --> 00:30:59,440 input system that lets you set 981 00:30:56,320 --> 00:31:00,720 named actions to certain keys so you can 982 00:30:59,440 --> 00:31:02,640 check for an actual key or you can check 983 00:31:00,720 --> 00:31:04,320 for a left right whatever it's a lot 984 00:31:02,640 --> 00:31:06,000 easier to name things like left or right 985 00:31:04,320 --> 00:31:07,279 so you can allow players or yourself to 986 00:31:06,000 --> 00:31:08,480 remap things 987 00:31:07,279 --> 00:31:10,559 so we're going to duplicate that for 988 00:31:08,480 --> 00:31:14,559 left right up and 989 00:31:10,559 --> 00:31:16,240 uh you guessed it down i can't type 990 00:31:14,559 --> 00:31:17,360 i might get the the directions wrong but 991 00:31:16,240 --> 00:31:18,640 i'm just going to take a guess right now 992 00:31:17,360 --> 00:31:20,000 so 993 00:31:18,640 --> 00:31:21,519 left is uh 994 00:31:20,000 --> 00:31:26,399 x1 995 00:31:21,519 --> 00:31:26,399 ui right is going to equal 2 minus 1 996 00:31:27,120 --> 00:31:30,799 minus 1 997 00:31:29,120 --> 00:31:32,960 yeah 998 00:31:30,799 --> 00:31:33,840 and 999 00:31:32,960 --> 00:31:35,840 yep 1000 00:31:33,840 --> 00:31:38,399 and we need so plus one for left minus 1001 00:31:35,840 --> 00:31:38,399 one for right 1002 00:31:40,480 --> 00:31:47,360 and z is our up 1003 00:31:43,919 --> 00:31:48,240 lowercase said not uppercase uh one 1004 00:31:47,360 --> 00:31:50,240 and 1005 00:31:48,240 --> 00:31:53,150 down 1006 00:31:50,240 --> 00:31:55,279 will will be uh 1007 00:31:53,150 --> 00:31:58,679 [Music] 1008 00:31:55,279 --> 00:31:58,679 minus one 1009 00:32:00,320 --> 00:32:05,039 right so yeah xyz 1010 00:32:03,760 --> 00:32:07,360 we want these keys to be able to move 1011 00:32:05,039 --> 00:32:09,200 the player around in the scene 1012 00:32:07,360 --> 00:32:10,960 now i can go project settings and you 1013 00:32:09,200 --> 00:32:12,640 can see where these are mapped 1014 00:32:10,960 --> 00:32:13,519 so in the input map you can see the ui 1015 00:32:12,640 --> 00:32:15,440 right 1016 00:32:13,519 --> 00:32:17,120 is mapped to a key or a d-pad so it's 1017 00:32:15,440 --> 00:32:18,320 mapped to uh 1018 00:32:17,120 --> 00:32:20,000 right 1019 00:32:18,320 --> 00:32:21,919 keyboard right 1020 00:32:20,000 --> 00:32:24,080 you can add your own name whatever you 1021 00:32:21,919 --> 00:32:25,440 like uh this is lets you abstract the 1022 00:32:24,080 --> 00:32:26,720 action away from the platform that 1023 00:32:25,440 --> 00:32:28,720 you're running the game on because goto 1024 00:32:26,720 --> 00:32:30,559 supports random consoles and ios and 1025 00:32:28,720 --> 00:32:32,640 gamepads and so on and so on and android 1026 00:32:30,559 --> 00:32:33,840 whatever you like 1027 00:32:32,640 --> 00:32:35,519 next thing we need to do is we're going 1028 00:32:33,840 --> 00:32:36,640 to normalize the direction so no matter 1029 00:32:35,519 --> 00:32:38,240 what direction we go when we're going at 1030 00:32:36,640 --> 00:32:41,880 the same speed so we're going to go 1031 00:32:38,240 --> 00:32:41,880 direction equals direction.normalized 1032 00:32:43,279 --> 00:32:47,760 if you want to do real game dev you need 1033 00:32:46,159 --> 00:32:49,840 to be okay with 3d movement it's not as 1034 00:32:47,760 --> 00:32:51,120 scary as it seems like it is 1035 00:32:49,840 --> 00:32:52,640 it's often 1036 00:32:51,120 --> 00:32:54,320 seems a lot scary than it actually is 1037 00:32:52,640 --> 00:32:55,519 it's quite okay 1038 00:32:54,320 --> 00:32:56,399 so 1039 00:32:55,519 --> 00:32:57,600 next thing 1040 00:32:56,399 --> 00:33:00,320 we're going to go 1041 00:32:57,600 --> 00:33:01,760 d equals d times move speed times delta 1042 00:33:00,320 --> 00:33:03,279 which basically makes it move at a nice 1043 00:33:01,760 --> 00:33:05,200 speed because we don't want to zoom off 1044 00:33:03,279 --> 00:33:07,279 in the distance too fast 1045 00:33:05,200 --> 00:33:08,480 that's pretty useful 1046 00:33:07,279 --> 00:33:09,760 so because this is being called every 1047 00:33:08,480 --> 00:33:10,640 physics tick we use the delta there as 1048 00:33:09,760 --> 00:33:11,919 well 1049 00:33:10,640 --> 00:33:13,679 uh because 1050 00:33:11,919 --> 00:33:15,840 if the frame weight 1051 00:33:13,679 --> 00:33:16,960 or the physics rate was inconsistent 1052 00:33:15,840 --> 00:33:18,480 then 1053 00:33:16,960 --> 00:33:20,320 not multiplying it by the delta would 1054 00:33:18,480 --> 00:33:21,760 mean the movement speed was jolty uh not 1055 00:33:20,320 --> 00:33:23,519 nice and smooth so this makes it nice 1056 00:33:21,760 --> 00:33:25,120 and smooth based on how your computer is 1057 00:33:23,519 --> 00:33:26,080 handling it 1058 00:33:25,120 --> 00:33:27,360 so 1059 00:33:26,080 --> 00:33:29,200 that just makes sure that handles it 1060 00:33:27,360 --> 00:33:32,159 properly 1061 00:33:29,200 --> 00:33:33,760 next thing we uh 1062 00:33:32,159 --> 00:33:35,519 if 1063 00:33:33,760 --> 00:33:37,360 we we want to fall faster than we jump 1064 00:33:35,519 --> 00:33:39,760 so if our velocity 1065 00:33:37,360 --> 00:33:42,320 on y is greater than zero so if we're 1066 00:33:39,760 --> 00:33:44,960 not jumping then we fall uh 1067 00:33:42,320 --> 00:33:48,320 if we are jumping then 1068 00:33:44,960 --> 00:33:50,240 the gravity is a different rate again 1069 00:33:48,320 --> 00:33:52,320 so video games are basically controlled 1070 00:33:50,240 --> 00:33:54,880 lying so gravity will affect us 1071 00:33:52,320 --> 00:33:56,480 differently when we jump basically uh 1072 00:33:54,880 --> 00:33:57,679 it's kind of like coyote time where you 1073 00:33:56,480 --> 00:33:59,679 know in the old cartoons when the kodi 1074 00:33:57,679 --> 00:34:01,200 falls off the uh the edge after being 1075 00:33:59,679 --> 00:34:03,919 off the edge already for a brief second 1076 00:34:01,200 --> 00:34:05,120 video games are basically that on a mass 1077 00:34:03,919 --> 00:34:06,640 scale 1078 00:34:05,120 --> 00:34:10,320 next thing we need to apply some gravity 1079 00:34:06,640 --> 00:34:11,520 so each physics step uh velocity on y 1080 00:34:10,320 --> 00:34:13,200 we 1081 00:34:11,520 --> 00:34:14,079 add some gravity 1082 00:34:13,200 --> 00:34:15,679 which is 1083 00:34:14,079 --> 00:34:17,760 multiplied by delta so it doesn't add 1084 00:34:15,679 --> 00:34:20,560 all the gravity at once 1085 00:34:17,760 --> 00:34:21,679 otherwise it'll just be be awful 1086 00:34:20,560 --> 00:34:23,200 that's uh 1087 00:34:21,679 --> 00:34:24,800 that's that 1088 00:34:23,200 --> 00:34:27,599 so once we've done that we also got 1089 00:34:24,800 --> 00:34:29,200 velocity.x equals direction.x so they're 1090 00:34:27,599 --> 00:34:30,800 the same 1091 00:34:29,200 --> 00:34:33,119 velocity is a three-part vector we also 1092 00:34:30,800 --> 00:34:35,280 need to z so direction.z so we only want 1093 00:34:33,119 --> 00:34:36,480 to modify the uh the y the the gravity 1094 00:34:35,280 --> 00:34:39,359 component of velocity we're not 1095 00:34:36,480 --> 00:34:40,320 modifying their otherwise velocity 1096 00:34:39,359 --> 00:34:41,520 so now we're going to actually make the 1097 00:34:40,320 --> 00:34:45,520 player move 1098 00:34:41,520 --> 00:34:47,919 so we're going to go velocity 1099 00:34:45,520 --> 00:34:48,879 and the velocity started at zero so 1100 00:34:47,919 --> 00:34:50,639 we're going to end with an actual 1101 00:34:48,879 --> 00:34:51,760 velocity we keep using 1102 00:34:50,639 --> 00:34:54,639 so we're going to use a function called 1103 00:34:51,760 --> 00:34:55,839 move and slide which is part of gotto 1104 00:34:54,639 --> 00:34:57,520 which basically 1105 00:34:55,839 --> 00:34:58,640 moves and hits stops you from hitting 1106 00:34:57,520 --> 00:35:00,800 something environment if it hits 1107 00:34:58,640 --> 00:35:01,760 something it comes to a stop 1108 00:35:00,800 --> 00:35:03,680 every game engine comes with an 1109 00:35:01,760 --> 00:35:05,839 equivalent of this function 1110 00:35:03,680 --> 00:35:08,000 move and slide is really quite useful 1111 00:35:05,839 --> 00:35:08,880 you can command click or control click 1112 00:35:08,000 --> 00:35:10,480 on 1113 00:35:08,880 --> 00:35:12,400 the function there and it gives you a 1114 00:35:10,480 --> 00:35:13,839 nice definition 1115 00:35:12,400 --> 00:35:14,960 moves the body along a vector if the 1116 00:35:13,839 --> 00:35:16,640 body collides with another body it will 1117 00:35:14,960 --> 00:35:17,760 slide along and stop 1118 00:35:16,640 --> 00:35:19,119 this means you don't have to calculate 1119 00:35:17,760 --> 00:35:20,880 all the fancy maths to move something 1120 00:35:19,119 --> 00:35:22,560 around in 3d space yourself and just 1121 00:35:20,880 --> 00:35:24,640 lets you use got it to do it so we floss 1122 00:35:22,560 --> 00:35:26,960 a velocity and a vector telling it which 1123 00:35:24,640 --> 00:35:29,839 way is uh up 1124 00:35:26,960 --> 00:35:32,960 and y is up 1125 00:35:29,839 --> 00:35:34,640 why why is up up is up 1126 00:35:32,960 --> 00:35:36,960 we also 1127 00:35:34,640 --> 00:35:38,880 want to be able to jump so if 1128 00:35:36,960 --> 00:35:40,560 is on floor which is another feature of 1129 00:35:38,880 --> 00:35:42,720 gotto 1130 00:35:40,560 --> 00:35:45,760 if we come and click on it it uh 1131 00:35:42,720 --> 00:35:47,440 returns true if the body is on the floor 1132 00:35:45,760 --> 00:35:49,200 so yeah it's very useful only updates 1133 00:35:47,440 --> 00:35:50,400 when calling move and slide uh it's 1134 00:35:49,200 --> 00:35:51,440 because the physics engine knows if 1135 00:35:50,400 --> 00:35:53,200 something is colliding with something 1136 00:35:51,440 --> 00:35:55,680 else that means it's on the floor 1137 00:35:53,200 --> 00:35:57,040 physics math can get hard really quickly 1138 00:35:55,680 --> 00:36:01,200 uh so we're gonna check if he's on floor 1139 00:35:57,040 --> 00:36:01,200 and input is action pressed 1140 00:36:01,520 --> 00:36:05,280 we're going to leave that blank for a 1141 00:36:03,440 --> 00:36:09,119 second and we'll come back to that 1142 00:36:05,280 --> 00:36:11,359 velocity dot y equals -10 so we want to 1143 00:36:09,119 --> 00:36:11,359 jump 1144 00:36:11,520 --> 00:36:16,160 yep 10 not a lot of 10 sorry yes 1145 00:36:14,160 --> 00:36:18,079 we want to go up that was an inverse 1146 00:36:16,160 --> 00:36:19,200 jump so if if we're on the floor and the 1147 00:36:18,079 --> 00:36:20,400 action press which will create the 1148 00:36:19,200 --> 00:36:22,640 second 1149 00:36:20,400 --> 00:36:24,320 is uh pressed so we're going to go into 1150 00:36:22,640 --> 00:36:26,720 our project settings 1151 00:36:24,320 --> 00:36:29,760 and in the input map and we're going to 1152 00:36:26,720 --> 00:36:31,680 go find game underscore jump 1153 00:36:29,760 --> 00:36:33,119 and click add 1154 00:36:31,680 --> 00:36:36,240 a game jump is at the end now i'm going 1155 00:36:33,119 --> 00:36:38,000 to map a key to that jump is a space bar 1156 00:36:36,240 --> 00:36:40,079 whoops 1157 00:36:38,000 --> 00:36:42,800 i want to map it to spacebar not control 1158 00:36:40,079 --> 00:36:44,160 add key space okay so now game 1159 00:36:42,800 --> 00:36:45,760 underscore jump action is mapped to 1160 00:36:44,160 --> 00:36:47,520 spacebar 1161 00:36:45,760 --> 00:36:50,480 so now i can provide the game underscore 1162 00:36:47,520 --> 00:36:52,720 jump action in that is action press call 1163 00:36:50,480 --> 00:36:55,440 it auto completes for me god is great 1164 00:36:52,720 --> 00:36:57,520 that's everything we need to do for now 1165 00:36:55,440 --> 00:36:59,200 in the script for our player so i'm 1166 00:36:57,520 --> 00:37:00,480 going to save player.gd with command s 1167 00:36:59,200 --> 00:37:02,240 or control s and go back into the 1168 00:37:00,480 --> 00:37:05,040 environment 1169 00:37:02,240 --> 00:37:06,480 i'm going to click my player 1170 00:37:05,040 --> 00:37:08,720 and the play now has a script attached 1171 00:37:06,480 --> 00:37:10,320 to it you can see over on the right side 1172 00:37:08,720 --> 00:37:11,599 there in the inspector player to duty 1173 00:37:10,320 --> 00:37:13,599 now i'm going to push command r to run 1174 00:37:11,599 --> 00:37:15,359 it and absolutely nothing will happen 1175 00:37:13,599 --> 00:37:17,280 because we haven't got a camera that was 1176 00:37:15,359 --> 00:37:18,880 deliberate by the way 1177 00:37:17,280 --> 00:37:20,240 very smooth it is doing things under the 1178 00:37:18,880 --> 00:37:21,599 hood but nothing is happening that we 1179 00:37:20,240 --> 00:37:23,200 can see 1180 00:37:21,599 --> 00:37:25,040 so i'm going to click the environment 1181 00:37:23,200 --> 00:37:26,480 and click plus for a new node and search 1182 00:37:25,040 --> 00:37:28,240 for a camera 1183 00:37:26,480 --> 00:37:29,760 and you'll see there's a camera node 1184 00:37:28,240 --> 00:37:31,680 guys got a bunch of cameras you've got 1185 00:37:29,760 --> 00:37:33,119 ar cameras and vr cameras all sorts of 1186 00:37:31,680 --> 00:37:34,320 stuff 1187 00:37:33,119 --> 00:37:36,320 you can see this frostum thing which 1188 00:37:34,320 --> 00:37:37,440 shows us where the camera is pointing so 1189 00:37:36,320 --> 00:37:38,560 you can see where the camera is pointing 1190 00:37:37,440 --> 00:37:39,520 with a little preview button so i'm 1191 00:37:38,560 --> 00:37:41,599 going to rotate the camera to have a 1192 00:37:39,520 --> 00:37:43,440 nice angle to make it slightly more 1193 00:37:41,599 --> 00:37:44,800 useful 1194 00:37:43,440 --> 00:37:46,720 that's slightly more useful a little bit 1195 00:37:44,800 --> 00:37:48,160 more rotation down and then we'll have a 1196 00:37:46,720 --> 00:37:49,440 nice camera 1197 00:37:48,160 --> 00:37:50,480 now if i run it we should have an actual 1198 00:37:49,440 --> 00:37:51,920 view 1199 00:37:50,480 --> 00:37:54,640 yep look at that oh we can move the 1200 00:37:51,920 --> 00:37:57,280 player with the mouse with the keyboard 1201 00:37:54,640 --> 00:37:59,200 you can even jump look at that 1202 00:37:57,280 --> 00:38:00,720 the the it falls a lot quicker than the 1203 00:37:59,200 --> 00:38:03,040 red it moves out which is great 1204 00:38:00,720 --> 00:38:05,200 everything seems to be working 1205 00:38:03,040 --> 00:38:07,760 the camera is not following the player 1206 00:38:05,200 --> 00:38:10,560 which is uh not very good but he he move 1207 00:38:07,760 --> 00:38:12,160 and slide works he hits the wall 1208 00:38:10,560 --> 00:38:14,560 they hit the wall it's doing very well 1209 00:38:12,160 --> 00:38:14,560 so far 1210 00:38:15,040 --> 00:38:19,520 we're going to continue improving this a 1211 00:38:17,040 --> 00:38:22,560 little bit 1212 00:38:19,520 --> 00:38:23,760 i can jump off the world too way 1213 00:38:22,560 --> 00:38:25,920 camera didn't follow me though so i'm 1214 00:38:23,760 --> 00:38:27,280 going to go back to godot 1215 00:38:25,920 --> 00:38:29,440 and i'm going to drag the camera onto 1216 00:38:27,280 --> 00:38:31,599 the player so now the camera is a child 1217 00:38:29,440 --> 00:38:33,839 of the player 1218 00:38:31,599 --> 00:38:36,079 the camera will now follow the player uh 1219 00:38:33,839 --> 00:38:38,400 this is a very crude camera follow you 1220 00:38:36,079 --> 00:38:39,839 could write a nice little script so the 1221 00:38:38,400 --> 00:38:41,359 player follows the camera follows the 1222 00:38:39,839 --> 00:38:43,839 play around like mario 64 so you have a 1223 00:38:41,359 --> 00:38:45,200 cameraman like a lerp and stuff a nice 1224 00:38:43,839 --> 00:38:46,880 flow but now the camera is following the 1225 00:38:45,200 --> 00:38:49,839 player at least so 1226 00:38:46,880 --> 00:38:50,960 this is a a lot better 1227 00:38:49,839 --> 00:38:53,119 i'm going to fix the key mapping because 1228 00:38:50,960 --> 00:38:55,200 the key map is actually backwards so i'm 1229 00:38:53,119 --> 00:38:57,839 going to go into 1230 00:38:55,200 --> 00:39:00,960 yeah okay just backwards forwards yep 1231 00:38:57,839 --> 00:39:02,480 go back into the gt script and modify 1232 00:39:00,960 --> 00:39:02,890 the key mapping 1233 00:39:02,480 --> 00:39:04,160 so 1234 00:39:02,890 --> 00:39:06,480 [Music] 1235 00:39:04,160 --> 00:39:09,520 plus equals one 1236 00:39:06,480 --> 00:39:11,599 yep and we're going to run that again 1237 00:39:09,520 --> 00:39:13,040 oh no 1238 00:39:11,599 --> 00:39:14,240 it's just rotated slightly sorry i've 1239 00:39:13,040 --> 00:39:16,640 got my keys around the wrong way so i'm 1240 00:39:14,240 --> 00:39:18,800 going to go ui 1241 00:39:16,640 --> 00:39:20,400 up 1242 00:39:18,800 --> 00:39:22,400 ui 1243 00:39:20,400 --> 00:39:23,599 down i'm 90 degrees relative to where i 1244 00:39:22,400 --> 00:39:26,480 needed to be 1245 00:39:23,599 --> 00:39:28,480 so you are left you are 1246 00:39:26,480 --> 00:39:30,079 right our left was forward 1247 00:39:28,480 --> 00:39:31,520 yeah 1248 00:39:30,079 --> 00:39:32,240 no strings so you need to yep there we 1249 00:39:31,520 --> 00:39:33,599 go 1250 00:39:32,240 --> 00:39:35,040 okay 1251 00:39:33,599 --> 00:39:36,240 perfect look at that now i can actually 1252 00:39:35,040 --> 00:39:37,680 control it 1253 00:39:36,240 --> 00:39:40,640 everything's working 1254 00:39:37,680 --> 00:39:43,359 now i can drive around get up the ramp 1255 00:39:40,640 --> 00:39:44,480 the a bit easy but there you have it 1256 00:39:43,359 --> 00:39:45,599 so we're going to make the goal work 1257 00:39:44,480 --> 00:39:49,280 next 1258 00:39:45,599 --> 00:39:51,440 i can push the ball oh look at that 1259 00:39:49,280 --> 00:39:52,800 okay there's no knowledge for the game 1260 00:39:51,440 --> 00:39:54,960 that it's called the goal though so 1261 00:39:52,800 --> 00:39:58,800 we're going to go into the environment 1262 00:39:54,960 --> 00:39:59,920 we're going to click on the uh ball 1263 00:39:58,800 --> 00:40:01,599 i'm going to tick the little box that 1264 00:39:59,920 --> 00:40:03,119 says can sleep 1265 00:40:01,599 --> 00:40:04,480 the ball's been falling asleep when it 1266 00:40:03,119 --> 00:40:06,800 doesn't move which means it doesn't 1267 00:40:04,480 --> 00:40:08,720 respond to physics very well 1268 00:40:06,800 --> 00:40:11,599 now pushing the ball around will be a 1269 00:40:08,720 --> 00:40:13,119 nice pleasant rolling experience 1270 00:40:11,599 --> 00:40:15,440 because the game was kind of putting the 1271 00:40:13,119 --> 00:40:17,119 physics system to sleep 1272 00:40:15,440 --> 00:40:19,680 look at that it rolls nicely instead of 1273 00:40:17,119 --> 00:40:21,040 just flying forward beautiful 1274 00:40:19,680 --> 00:40:23,119 i'm gonna add a little bit of code to 1275 00:40:21,040 --> 00:40:24,640 make the goal know when the uh the ball 1276 00:40:23,119 --> 00:40:26,000 has gone through it 1277 00:40:24,640 --> 00:40:28,960 so 1278 00:40:26,000 --> 00:40:30,560 first thing i'm going to do is go into 1279 00:40:28,960 --> 00:40:32,400 environment and add a script to the 1280 00:40:30,560 --> 00:40:35,200 environment 1281 00:40:32,400 --> 00:40:36,319 which will let us reset the game so this 1282 00:40:35,200 --> 00:40:39,319 means we have to restart the game 1283 00:40:36,319 --> 00:40:39,319 constantly 1284 00:40:40,079 --> 00:40:43,839 so uh tweaking the game is a lot easier 1285 00:40:41,680 --> 00:40:45,839 when you can reset the game in the 1286 00:40:43,839 --> 00:40:48,800 process uh call which is called every 1287 00:40:45,839 --> 00:40:50,480 frame i'm gonna go if input key pressed 1288 00:40:48,800 --> 00:40:51,920 key enter so unlike before where we 1289 00:40:50,480 --> 00:40:54,079 mapped a nice action we're going to 1290 00:40:51,920 --> 00:40:55,760 brute force map the enter key i'm going 1291 00:40:54,079 --> 00:40:58,240 to go get tree which just gets the whole 1292 00:40:55,760 --> 00:41:00,560 node tree and reload current scene so 1293 00:40:58,240 --> 00:41:02,720 now when i push enter the game resets 1294 00:41:00,560 --> 00:41:05,119 look at that beautiful 1295 00:41:02,720 --> 00:41:07,440 extremely useful 1296 00:41:05,119 --> 00:41:09,440 with that in place i'm going to go to 1297 00:41:07,440 --> 00:41:11,680 the uh 1298 00:41:09,440 --> 00:41:13,280 the goal 1299 00:41:11,680 --> 00:41:14,640 on the upper platform i'm going to add 1300 00:41:13,280 --> 00:41:16,400 an area so i'm going to move the scene a 1301 00:41:14,640 --> 00:41:17,760 little bit so i can see what's going on 1302 00:41:16,400 --> 00:41:19,280 i'm going to click on the upper floor 1303 00:41:17,760 --> 00:41:20,720 and i'm going to add an area to that 1304 00:41:19,280 --> 00:41:22,960 which is the same kind of volume thing 1305 00:41:20,720 --> 00:41:24,720 you saw earlier 1306 00:41:22,960 --> 00:41:26,960 there's the area 1307 00:41:24,720 --> 00:41:28,400 so i'm not adding the goal to the goals 1308 00:41:26,960 --> 00:41:30,640 scene i'm actually adding the goal to 1309 00:41:28,400 --> 00:41:32,400 the the main environment scenes it kind 1310 00:41:30,640 --> 00:41:34,800 of is overlapping the place where the 1311 00:41:32,400 --> 00:41:36,400 goal is in that scene just for detection 1312 00:41:34,800 --> 00:41:38,319 purposes and to make scripting slightly 1313 00:41:36,400 --> 00:41:40,480 easier so in that area i'm going to add 1314 00:41:38,319 --> 00:41:42,079 a collision shape 1315 00:41:40,480 --> 00:41:43,200 collision shape 1316 00:41:42,079 --> 00:41:45,440 and add a 1317 00:41:43,200 --> 00:41:48,160 box so this box basically says what 1318 00:41:45,440 --> 00:41:49,839 shape is the area that is detected this 1319 00:41:48,160 --> 00:41:51,520 is the area the invisible area that can 1320 00:41:49,839 --> 00:41:52,560 detect when something is inside it so 1321 00:41:51,520 --> 00:41:54,240 you can see the invisible area 1322 00:41:52,560 --> 00:41:55,760 represented by those uh 1323 00:41:54,240 --> 00:41:56,960 those lines 1324 00:41:55,760 --> 00:42:00,480 anytime the ball goes through the area 1325 00:41:56,960 --> 00:42:01,520 we score a goal this is a very easy game 1326 00:42:00,480 --> 00:42:03,359 i'm going to make a tiny bit thinner 1327 00:42:01,520 --> 00:42:05,200 just slightly less easy 1328 00:42:03,359 --> 00:42:08,800 that's better yep okay now it's not so 1329 00:42:05,200 --> 00:42:10,160 so easy uh with the goal ready to go we 1330 00:42:08,800 --> 00:42:12,560 need to actually do the scripting 1331 00:42:10,160 --> 00:42:14,800 component so we're gonna add a script to 1332 00:42:12,560 --> 00:42:17,200 the game to let us score that goal so 1333 00:42:14,800 --> 00:42:18,400 i'm going to click on the area 1334 00:42:17,200 --> 00:42:20,160 i'm going to go 1335 00:42:18,400 --> 00:42:22,160 node 1336 00:42:20,160 --> 00:42:23,359 and you'll see this node emits a bunch 1337 00:42:22,160 --> 00:42:25,040 of signals 1338 00:42:23,359 --> 00:42:27,040 so these signals are things that can be 1339 00:42:25,040 --> 00:42:30,960 connected up to code to make it do 1340 00:42:27,040 --> 00:42:32,800 things so the area emits a body entered 1341 00:42:30,960 --> 00:42:34,319 signal and tells us which body entered 1342 00:42:32,800 --> 00:42:36,000 it so i'm going to click body entered 1343 00:42:34,319 --> 00:42:37,040 click connect 1344 00:42:36,000 --> 00:42:38,480 it's going to ask me where i want to 1345 00:42:37,040 --> 00:42:40,480 connect it to 1346 00:42:38,480 --> 00:42:41,440 i'm going to connect to the environment 1347 00:42:40,480 --> 00:42:44,319 which 1348 00:42:41,440 --> 00:42:46,640 adds a on area body entered function to 1349 00:42:44,319 --> 00:42:47,760 the environment script that we created 1350 00:42:46,640 --> 00:42:49,839 so i'm going to delete the contents of 1351 00:42:47,760 --> 00:42:50,880 that and inside that i'm going to go if 1352 00:42:49,839 --> 00:42:53,119 body 1353 00:42:50,880 --> 00:42:54,640 is rigid body 1354 00:42:53,119 --> 00:42:57,040 which basically means it can only be the 1355 00:42:54,640 --> 00:42:57,040 player 1356 00:42:57,440 --> 00:43:01,359 i'm going to print hooray goal we 1357 00:42:59,839 --> 00:43:02,960 haven't got time to make a ui today but 1358 00:43:01,359 --> 00:43:04,800 uh this will print a nice little message 1359 00:43:02,960 --> 00:43:07,359 to the console when the player goes 1360 00:43:04,800 --> 00:43:07,359 through the goal 1361 00:43:07,760 --> 00:43:12,960 sorry the ball goes through the goal 1362 00:43:10,560 --> 00:43:15,040 i'm going to move up here i'm gonna push 1363 00:43:12,960 --> 00:43:18,240 the ball through the goal 1364 00:43:15,040 --> 00:43:19,359 and it says hooray goal 1365 00:43:18,240 --> 00:43:20,560 because it knows the ball has gone 1366 00:43:19,359 --> 00:43:22,720 through because it can only detect the 1367 00:43:20,560 --> 00:43:25,720 ball the ball is the rigid body 1368 00:43:22,720 --> 00:43:25,720 amazing 1369 00:43:26,000 --> 00:43:29,440 that's pretty much our whole game 1370 00:43:28,319 --> 00:43:30,640 i'm going to go quickly and make the 1371 00:43:29,440 --> 00:43:32,480 power up do something because we've got 1372 00:43:30,640 --> 00:43:35,359 a little bit of a second to do that i'm 1373 00:43:32,480 --> 00:43:35,359 going to click on the cube 1374 00:43:36,640 --> 00:43:39,520 i'm going to add a script to it 1375 00:43:38,240 --> 00:43:42,000 everything needs a script attached 1376 00:43:39,520 --> 00:43:43,200 script pick up inside that script i'm 1377 00:43:42,000 --> 00:43:46,000 going to 1378 00:43:43,200 --> 00:43:48,480 uncomment process so every single frame 1379 00:43:46,000 --> 00:43:54,160 please rotate so we're going to rotate 1380 00:43:48,480 --> 00:43:55,839 dot x underscore x deg to rad 1381 00:43:54,160 --> 00:43:57,119 so process is called literally every 1382 00:43:55,839 --> 00:44:00,720 frame 1383 00:43:57,119 --> 00:44:02,640 so we're going to uh basically rotate it 1384 00:44:00,720 --> 00:44:06,240 uh at the delta rate 1385 00:44:02,640 --> 00:44:07,280 on the x and rotate it on the y 1386 00:44:06,240 --> 00:44:08,960 we're going to run it and narrow our 1387 00:44:07,280 --> 00:44:12,160 cube we'll spin like a proper video game 1388 00:44:08,960 --> 00:44:14,640 power up so that was gotto hope you 1389 00:44:12,160 --> 00:44:16,079 enjoyed it uh please dive into it and 1390 00:44:14,640 --> 00:44:17,520 build more things or extend this silly 1391 00:44:16,079 --> 00:44:19,280 little game please tweet me little any 1392 00:44:17,520 --> 00:44:22,000 questions you have uh thank you for 1393 00:44:19,280 --> 00:44:23,520 watching hope you're all staying safe uh 1394 00:44:22,000 --> 00:44:25,839 you can export your game to mac linux 1395 00:44:23,520 --> 00:44:27,760 android consoles a whole bunch of things 1396 00:44:25,839 --> 00:44:29,280 thanks very much 1397 00:44:27,760 --> 00:44:31,200 hello everyone and thank you so much for 1398 00:44:29,280 --> 00:44:32,720 your talk paris i there was some great 1399 00:44:31,200 --> 00:44:34,480 chat in the 1400 00:44:32,720 --> 00:44:35,520 chat room during that which was really 1401 00:44:34,480 --> 00:44:38,079 great to see 1402 00:44:35,520 --> 00:44:39,359 um if you had any questions for paris i 1403 00:44:38,079 --> 00:44:41,440 hope you asked them during the chat that 1404 00:44:39,359 --> 00:44:43,040 was a really great presentation seems 1405 00:44:41,440 --> 00:44:45,440 like a really cool tool 1406 00:44:43,040 --> 00:44:46,880 uh next up we have a break 1407 00:44:45,440 --> 00:44:49,040 is a great time to get up stretch your 1408 00:44:46,880 --> 00:44:51,040 legs stretch your hands eat some food 1409 00:44:49,040 --> 00:44:52,960 drink some coffee pat your cats send 1410 00:44:51,040 --> 00:44:55,839 photos of the cats to the pets of lca 1411 00:44:52,960 --> 00:44:58,560 channel and venulis 1412 00:44:55,839 --> 00:45:00,079 or go to the linux agm which is at 12 30 1413 00:44:58,560 --> 00:45:01,200 and if you're a member of linux 1414 00:45:00,079 --> 00:45:03,200 australia you should have got an email 1415 00:45:01,200 --> 00:45:04,960 about that 1416 00:45:03,200 --> 00:45:07,359 so the next talk in this room is after 1417 00:45:04,960 --> 00:45:09,599 lunch at 1 30 pm aedt 1418 00:45:07,359 --> 00:45:11,520 uh from russell coca it's 20 years of 1419 00:45:09,599 --> 00:45:12,960 nsa security enhanced linux 1420 00:45:11,520 --> 00:45:15,599 retrospective 1421 00:45:12,960 --> 00:45:17,520 so i'll see you all uh there or in later 1422 00:45:15,599 --> 00:45:21,640 talk or later on 1423 00:45:17,520 --> 00:45:21,640 have great have a great lunch