How to create a Car Racing Game in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys my name is Abdula and if you have ever wanted to create your very own car game inside of hun Engine 5 then this course is going to be perfect for you because in this course we're going to be creating a car game in h Engine 5 from scratch we're going to be importing the model of the car uh we're going to be rigging it we're going to be making the car drivable and after that we're going to be adding textur to the car and making it look hyper realistic um then we're also going to be working on a whole timer system a whole checkpoint system and a Finish Line system which is going to sort of create the mechanics of the game and make the game actually enjoyable to play um after that we're going to be covering the whole world building process of an actual game um and so what we're going to be doing is are we're firstly going to be creating roads we're going to be creating um the board for checkpoints and everything we're going to be creating uh we're going to be adding buildings we're going to be creating a whole park inside the game we're going to be adding the street lights traffic lights trees and a lot more to make the game hyper realistic and very enjoyable to play we're also going to be covering my full workflow of lighting the scene and applying textures so that we can learn how to make the game hyper realistic and very appealing to the player now this course is mainly a aim towards Unreal Engine beginners who have very little to know experience inside of under Engine 5 however knowing how to use at least one 3D software like maybe blender would be definitely helpful I personally would recommend you to use blender but if you want to use any other 3D software that's going to be perfectly fine as well and even if you are experienced inside of under Lon 5 I would actually still recommend you to take this course because in this we're going to be covering a lot of workflow tips and we I'm going to be giving you shortcuts for different things so no matter if you have experience in unv engine or not you will definitely take something from this course but yeah I really hope you guys are as excited as I am and I will see you inside the course all right guys welcome to the course now let's begin the course with obviously creating an under Lon project um so what I did was I open Unreal Engine and you can just go to games and in here we're just going to go to vehicle so with vehicle what's going to happen is that it's going to give us like a basic track and like some basic blueprints which we which we can like use to you know just work with our project you can also go uh you can also just choose a blank uh project however a vehicle project is just going to give us some tools which we're going to which are going to just make our project a little easier uh make sure to select blueprint cuz we're going to be using uh blueprints for the coding part and Target platform should be desktop um Quality PR at maximum and if you can if you have a Nvidia RTX graphic card be sure to turn on rate racing CU it's going to make your um it's going to make your uh project look a lot better it's going to make your game lighting look a lot better the Shadows look a lot better so yeah just be sure to turn it on if you can if you can't that's perfectly fine as well so project name is just I'm just going to be naming it um unreal actually racing game course that should be fine and project location I'm just going to set it to default and then we can just go ahead and press create so it's just going to create a brand new project for us and so right now what I'm going to be doing is that I'm just going to be opening blender and we're going to be adding the car and rigging the car inside of blender before we can go ahead and add it to Unreal Engine and while that happens while we do that we're also going to let this uh let Unreal Engine to compile are shaders for us okay so you can also do this um in any other 3D software by the way other than blender if you prefer that but I just personally prefer blender so I'm just going to go ahead and open blender so um and yeah I'm just going to go ahead and delete everything that we have in our scene now I am assuming that you know the basics the very basics of blender 3D if you don't know that I think you should be fine cuz I'm going to try to you know explain what I'm doing um as often as I can so um what I'm going to do is that I'm going to go to the internet and I'm just going to be searching for for car um 3D model so what we can do is we can just go to sketch faab sketch VB is the website which I usually prefer for um a 3D model and all that stuff uh so what I'm going to do is actually I'm just going to actually we can just go back to sketch faab we can go to explore downloadable and then we can into in categories we can just do cars and vehicles right so you have all these cards which you can download and use um think I like this one though but what I did in my original project was I used a Porsche 911 so I'm just going to be searching that so um which one was I think mine was this one so I'm just going to be using this one just to be on the safe side you know um cuz some uh some cars uh which I tried to rig were like their shading was a little off the shading was a little um some cars were a little like low poly you know um so what I would recommend you to do is make sure that the number of triangles is like quite a lot okay uh so for example if I go to I want to show you an example of a car with like low a low number of triangles so yeah if you want something like this oops my bad under engine opened um if you use something like this you're going to see that it only has 2.4k triangles so this obviously is not going to look that realistic right so the more triangles your car has the better the more realistic it's going to look um generally but like obviously there's a limit to that of course if it has like a ton of triangles then obviously it's going to affect performance a lot but anyways so we can just go ahead and download this 3D model click download and it luckily it does come with the blend format uh in in a blend format but what you can do is you can also just download a gitf usually blender can open gitf without any problems so um yeah but I'm just going to go ahead and download the blend format but assuming you were to download the G format what you would do is you would just open your blender project go to file import and then you just going to go to onto gitf and just select your file wherever you have that saved okay so I'm just going to go to downloads now and I'm just going to be opening this file source and this is the blender file so what I'm going to do is that actually I'm just going to copy this whole folder I'm going to drag it on my desktop like that so I usually like to keep all my stuff on the desktop while I'm working but when I'm done I usually just paste all that stuff in a folder and I just like you know just clear up my desktop anyways so what I can do is I can actually go ahead and close blender for now and I can just open this brand new project now this project is going to come with this car so um if you want to move uh if you want to like rotate your camera like this in blender what you do is you just hold down your middle Mouse button um so that's how you do that I just wanted to like give you uh I'm just going to give you like a little bit of tips for blender as well along the way but anyways so we have this car it looks pretty good now what we're going to have to do is we're going to have to go ahead and make sure that our whole body is one object and our tires all four tires are separate objects right so how how do how exactly do we do that what we do is that we basically just select um different objects and then we compile uh basically we just join them into a group but before that make sure that everything uh like for all of these objects there are no modifiers applied but there are no modifiers which are not applied make sure that you apply all modifiers so I'm just going to go through this and if if obviously any of these have a modifier it's going to just show up here so I'm just going to like look out for those I'm just making sure that none of these have any modifi cuz if they have modifiers what happens is that the shading gets a little janky and it usually doesn't look that great and also I'm just going to go back to object mode cuz I think this is a lot easier to work with but yeah let's start with the front left tire so what I'm going to do is that I'm going to select the tire um all the parts of the tire and you can obviously do some trial and error and how do you make sure that you selected all parts you simp simply press G and move it to see that you have selected all parts I think I have except for this part right here so I'm just going to do contrl Z and then I'm going to select this part as well also make sure that you hold shift on your keyboard while selecting objects so that that way you can like select all of them now make sure that all of them are selected yep they are and now what we can do is we can just simply press contrl J with all of them selected and that's just going to join them into one object so we can move it and if you um also the way we move it is by pressing G um so you can right click to reset the position and now what I'm going to do is I'm just going to select this and we're just going to browse over to the tire itself and I'm just going to rename it to um wheel oh my bad wheel um front left FL okay that's how we usually name tires of cars okay front left now let's move on to the rear left tire uh the wheel so I'm just going to be selecting all of the objects very carefully just like that g to move it I think I have selected everything what's this no okay yeah I think I've selected everything so what I'm going to do is that I'm going to press control J and that's just going to compile it into not compile it's just going to join them into one object actually we're just going to name these at the end let me just select all of them first now this part is obviously going to depend on the car that you pick so um if if this is your first project be sure to like not pick like a very um complex car cuz some cars are going to be like very you know they're going to have like a lot of parts so I would recommend you to start off with like a easy basic car and I think this Porche 901 is probably the best place to start um control J and yeah okay so now what I'm going to do is that I'm going to name all these tires so so I'm just going to select this one this is the rear left so wheel RR actually RL this one should be RR wheel underscore r [Music] r and oops my bad wheel underscore front right okay now let's make sure that we've named everything correctly so I'm just going to be going here front left front right rear left and rear right perfect we've named everything correctly so now what I'm going to do is that I'm just going to be uh selecting anything right you can just select anything you want also by the way be sure to press contrl s to save your project but yeah um I'm just going to be selecting anything press a to select everything and now what I'm going to do is that I'm going to press shift and I'm going to click the wheel twice that's it's basically to deselect it so if you click it twice you're going to see that it's just going to deselect the wheels so now what we have is we have selected everything apart from the wheels so if I just try to move it you're going to see that this is the whole body of the car contrl + z so now with all of them selected what I'm going to do is that I'm just just going to be pressing shift and just selecting anything to make it the active selected object cuz if I do it without that um it's just going to give me an error so let me just show you the error first and then we can I'm just going to show you the solution so if I press contrl Z and like deselect that so now now you're going to see that all of them are dark orange right none of them is yellow okay so if I press control+ J you're going to see that it says active object is not a selected mesh I don't know if you can see that or it's cut off but there's an error down below so what I'm going to do is that I'm just going to press shift and select anything anything basically on this uh uh mesh and I'm just going to press contrl J so now you're going to see that this whole body is just going to become one um part okay that's perfect so now what we have in our collection is that we have the wheels and then we have the main body so I'm just going to name it the body and now we're done with essentially uh setting up the car for rigging now we just have to make sure that we have applied um applied the rotation and the transformation and everything like that so what I'm going to do is that I'm going to press uh press a also by the way in blender you don't press contr a you just press a so that's just a quick little tip for you um and I'm just going to be rotating it by pressing R and then Z to rotate it in the z-axis and then 9 90 to rotate it actually no positive 90 cuz we're we're going to have to make sure that the car is facing uh the positive of the x-axis and the way I know that this side is positive x-axis is by looking at this it says X towards there so that means it's um positive x-axis so r z and then 90 like that perfect so now we're going to also going to make sure that our individual um basically our uh Origins for the individual measur are also oriented correctly so I'm just going to select this mode uh this move tool right here now this part is a little important what you're going to do is that you're going to go to local and make sure that these uh these like um what do you call it these movement things they align with uh the actual like world world axis as well so this x is pointing towards the y axis right the positive Y axis which is not good that's not what we want so the way we rotate this is by basically just um going to the rotate tool and then just going up to options right here and make sure that transform effect only is set to Origins so this is just going to rotate the origins um and nothing else okay so what I'm going to do is that I'm going to be rotating it like this and also be sure to hold um shift to rotate in increments actually no control to rotate in increments and make sure that you rotate it exactly 90° or actually no not 90 um let me actually go to the top view and rotate it like that exactly um I think it wasn't like oriented perfectly actually was yeah 90° like that okay so now you're going to see that the x-axis is facing the x-axis the y- axis although is not facing the y- axis right so we got to rotate it like this as well 90° and now you're going to see that is perfectly fine that the z- axis is facing the z- axis and y to Y and X to X perfect now we can just go ahead and turn this off and select the move tool you're going to see that this is perfectly aligned okay and so we're going to have to do this the problem with this is that we're going to have to do this individually for all um the tires so let's actually go ahead and just do that now this is probably the most boring part of this whole um course so don't worry this is not that boring um later on yeah I think it's pretty fun to like you know make a game and uh especially like if you if you're like into playing games for me this whole project was like very fun honestly but yeah um so like that and then like this perfect and this as well so with this I'm just going to be rotating the x axis to align that and also up up here you can see um just just make sure that you focus right here you're going to see the degrees that we're rotating it too that's how you know that you're Rota rotating it correctly you're going to see that it says rotation minus 90 local up there on the top left side so that's how you make sure that you're rotating it correctly and lastly this one perfect I think we should be good just make sure to turn this off and make sure to go to the top view and make sure that all the origins are the same perfect so we are good to go now we can go ahead and rig this car so for rigging the process is pretty simp pretty simple what you're going to have to do is you're going to have to go to the internet and you're going to have have to go to this website right here Contin break.com creations4 vehicle rigging addon blender and so this is basically an add-on which is made for under engine and it's made for blender to rig vehicles for under engine so what we do is we just go to the this website and we just go to download it's going to take you to gumroad and you can obviously pay for it if you want but if you typee in zero that's perfectly fine as well and then it's just going to uh and then you can just press get and it's going to send you an email with this add-on so I already have this uh this add-on installed but I'm going to show you how to install it as well but yeah once you have downloaded that file from your email what you're going to have to do is you're going to have to go to edit preferences and cl click add-ons okay and then you're just going to have to go to install and then go to downloads or wherever you have that addon installed U add-on downloaded and then just select that add-on and press install add-on make sure it's a zip file and that should be perfectly fine so once you have that installed you're just going to have you're just going to see it right here but I'm just going to search it ue4 actually vehicle yeah on Engine 4 vehicle riger just make sure that this is checked it's turned on it's not going to be turned on by default by the way you're going to have to turn it on yourself so once that is done you're going to see it right here if you don't have this menu by the way you can just um you can just just click this button right here and it's going to open up this menu for you so you can just go to ue4 vehicle and then you can start rigging um the car okay so what I'm going to do is that firstly the vehicle base is obviously going to be this body so we're just going to set that in uh wheel front right it's just going to be the wheel front right wheel rear right is going to be the wheel rear right wheel front left is going to be the wheel front left and the wheel um front wheel rear left is going to be such a tongue twister is the whe wheel rear left is going to be the wheel rear left perfect so once we have all these um basically Parts set up which we what are we going to do what we're going to do is we're going to have we're going to go ahead and press rig vehicle but right now you can see that it's gred out so before that what we're going to do is we're going to set unit scale now you're not going to notice anything happen but if I just go ahead and open up the measure tool open up the measure tool you're going to see if I go to side view and if I measure this you're going to see that it's literally 0.01 M so that's very small that's not what we want so what I'm going to do is that I'm just going to go ahead and add a cube and you're going to see that the default cube is that much bigger so basically just make sure that the um what do you call it the units are the same for Unreal Engine and blender which they are by default they're not so we're going to have to like you know scale it according to Unreal Engine so what I'm going to do is that I'm going to click this button right here to make sure that we can see through the cube as well and let's first measure it so I think we want it we want the card to be something like this long okay so I'm just going to select the cube move it up this is just for reference the cube is just for reference so also if you if you're not sure about the height of your car so what you can do is you can just search for your car name on Google and then height so that's just going to give you the height but yeah I'm just going to select all these parts and I'm going to press s and scale them up like that till it hits the top of the cube cuz so the cube what we did with the cube was we just used it for a reference to make sure that our uh scaling is fine so I'm just going to move the tires a little up by the way you use G to move up so now you can press alt Z or just click this button right here to go back to the solid View mode and we can just go ahead and delete this Cube so now you're going to see that the vehicle is perfectly ready for rigging um but before that one last step I'm really sorry uh there are a quite a lot of steps I do understand that but this is trust me this is probably the most boring part of this tutorial everything after this is super fun but yeah so we're going to have to go ahead right here click this and click face orientation and make sure everything make sure everything on the outside is blue if anything is red what you're going to do is you're going to select that object press tab to go into edit mode press a to select everything select all it's everything was selected by default by the way go to mesh normals and then flip okay make sure that all the red faces are selected only the red faces are selected and so yeah that's how you invert normal so if any if anything doesn't have like a correct normal you're going to see if I move far you're going to see that the window is becoming and like some parts of the car are becoming red but that doesn't really matter cuz that's from the inside if I show you from the inside of the car you're going to see that some parts are red from the inside but that doesn't really matter cuz we're going to be looking at the car from the outside right make sure everything from the outside of the car is blue that's just going to make sure that it looks good in Unreal Engine otherwise it's going to look super weird so I'm just going to go ahead and turn off the face orientation so now we can just go ahead and click rig vehicle and that's perfect fine our vehicle is finally finally rigged now make sure after rigging the vehicle that you once again uh go to object mode and then once again just make sure that the face orientation is fine cuz sometimes when you rig cars or when you like join objects it is going to mess up the normals sometimes but like thankfully this is not the case with us perfect so now our c is ready to be exported out to Unreal Engine so what I'm going to do is that I'm just going to go to file actually make sure to save the project before go to file export and then FP FX so we're going to be exporting this as an fpx file and then we can just go to desktop and I can just make a folder called game course assets so and inside this we can just drop [Music] car actually no Porsche cuz we might add more cars later yeah this is the car model perfect so everything should be exported now let's move on to Unreal Engine and then we can simply just create a create a level and then we can import this car into Unreal Engine so now I'm just going to minimize blender uh I'm not going to close it right now cuz we might have to come back to it and maybe maybe import some things again but yeah if you open Unreal Engine by default it should look something like this this content browser is a separate window for now I don't know why but like I'm just going to close it um and because we have our content drawer right here so what I usually like to do is I usually just like to open the content draw drawer and then just dock it in layout so that we have it whenever we want it right cuz it's a pretty important part of our um what do you call it our whole game okay so now let me just give you a basic rundown of how Unreal Engine uh how to move an Unreal Engine and how the editor works so what you're going to do is you're going to have to right click with your mouse and then you can just move your mouse to look around and you can use the W ASD Keys like firsters shooter game uh to move um in like two dimensions and then in the third dimension what you can do is you can press Q to go down and e to go up so that's how you move in Unreal Engine right so this basically this this game comes with like a basic track we're not going to be using this though you can use it if you want uh but I'm just going to be like building everything from scratch uh but also you can just go ahead and press play to see how this game looks so this basically um yeah so this essentially just comes with a pre-made game and uh yeah so that's how this is right now yeah this game the physics of this game is like are pretty basic we're going to be hopefully making our game look a lot better um but yeah so I'm just going to press escape to get out of the get out of the game but yeah what I'm going to do is I'm actually just going to be importing the car for now and then we can just go ahead and set up the car and then we can just start making the world and we're going to be changing everything in this uh world but yeah uh right now let's just leave it as it is so what I'm going to do here is that I'm just going to be right clicking the Contour folder and I'm going to be creating a new folder and let me just call this uh game underscore actually game assets like that and then what I can do is I can just simply go ahead and right click again oops right click here and create a new folder again and I can just name this car car should be fine and now what I can do is I can go to file explorer and just browse to wherever I had that saved so this file I'm just going to be dragging this file right inside the content drawer and now these settings are relatively important so what you're going to do is you're going to have to make sure that skeleton mesh and import mesh is turned on and go down and create new materials this is turned on as well this is pretty important so once you click import all you're going to have to wait for a bit but then the mesh should hopefully be imported properly okay so it just gave us some uh some errors but that doesn't really matter so we can just go ahead and cross it out now you're going to see that we have a lot of materials which is pretty good cuz we obviously need materials and then down here we have three things the skeletal mesh skeleton and physics asset now the first thing I I like to do is I just like to import the I just like to like drag in the skeletal mesh into our scene and just inspect it to make sure nothing is wrong with the mesh cuz you cuz sometimes what happens is that some normals won't be fine some uh some shading won't be fine so just make sure that everything is fine which I think it's pretty decent yeah the whole mesh is pretty decent and yeah I think we should be good to go uh with like the whole um setting this vehicle up part make sure to save all and press contrl S as well those two things are not the same and they're different in engine for some reason but yeah make sure to do both okay so now what we're going to do is that we're going to have to uh install a plugin which basically comes with Unreal Engine but it's not enabled by default so we're going to have to go ahead and enable that so I'm just going to go to settings plugins and then we can just search for chaos so if we actually yeah chaos vehicle plugins make sure that make sure that this is checked uh but actually yeah we since we're in the car project already so in the car project it is turned on by default but if you did blank you're going to have to turn this on by yourself so now we can go ahead and um set up the car basically make the car drivable all right so now what we can do is that we can just go ahead and first thing what I'm going to do is that I'm I'm just going to select all these materials and I'm just going to actually let me just create a new folder first new folder materials and then just select all these and just drag them into this folder just to like you know make things a little more organized uh so what we can do is we can just right click this and actually uh yeah we can just do it here CU I was thinking of creating another subfolder but I think that's going to be a little too much um but we can just go ahead and create a blueprint class so I'm going to click all classes and I'm just going to be searching for wield vehicle Pawn so this is what we're going to be creating and just select this and create it and I'm just going to be naming this car BP for blueprint and we can just go ahead and open this so now you're going to see that in this what we're going to be doing is that we're just going to be adding the car right so we're just going to go to mesh and we're going to select the skeletal mesh asset we're just going to be setting it to the Porsche 911 and that should be it that's basically our car in it so now what we're going to be doing is that we're firstly going to be adding a camera but so a camera is going to be mounted onto a spring arm which is basically an arm which is going to like you know just control the camera movement um but I'm just going to be adding a spring arm spring arm and so the spring arm is basically going to be parented to the mesh so that like let me give you an example so if we like you can see this is the spring AR right so if we move the mesh actually I don't think we can move the mesh but like yeah if we were to move the mesh the spring arm is going to go with it right that's exactly what it is so and then we're just going to be adding a camera as well so if you add a camera and now this camera this is where parenting comes into play so if I move the spring arm you're going to see that the camera is going to move with it and that's exactly where we're going to be doing we're not going to be moving the camera we're just going to be moving the spring arm cuz the camera is sort of attached to the spring arm so I'm just going to be moving it somewhere there let's rotate it too a little bit so I think that should be like a good um starting point for our oops my bad we should probably move it a little higher something like that actually no that's a little too high but yeah well above yeah we can obviously tweak this later but yeah for now I think this should be a good starting view okay so now let's go ahead and actually compile this first and then let's configure the vehicle itself so the vehicle has basically a few components it has the engine it has um the wheels obviously and so we're going to have to configure all those one by one so let's actually start with the wheels CU obviously the wheels are the like wheels are what what's going to basically move and all that right right so let's go ahead and go to the wheel setup and in this wheel setup we're going to be this is basically an array right so we're going to adding we're going to be adding four array elements cuz we have four wheels so now firstly we're going to be uh adding the bone names so the bone names are going to be basically um if you follow this tutorial exactly um they should be uh what do you call it front right um and then front left and then rear left oh rear right and then rear left but I'm I'm going to be telling you how to check these as well if you don't know the exact names right left let me compile this if you want to know these names what you can do is you can just go to the physics asset and here you're going to see that we have this front left front right rear left and rear right okay where we are going to be configuring the physics asset later on but right now we don't need to worry about that so that should be fine okay so one thing which I which I'm going to change is that we're going to be starting with the left wheel first because um I did some research and apparently you're supposed to uh I watched a few YouTube and apparently you're supposed to yeah start with the left first okay so let's do that and let's save it now so now we also need a wheel class as well so for the wheel class what we're going to what we're going to be doing is that we're just going to be right clicking this blueprint class and then we're going to be searching for chaos and then just says chaos vehicle vehicle wheel so select that and we are going to be send just the actually wheel front BP and we are going to be duplicating this so just duplicate and wheel back rear basically rear BP perfect so now we have two uh wheel blueprints so we can just go ahead and add them so I'm just going to be selecting the wheel class and then wheel front to BP cuz this is the front front BP and for the second to we're going to be selecting the wheel rear BP now we are going to be making changes to this of course but yeah for now let's just compile this let's close this and this perfect so now we can just go ahead and open the wheel so in this we don't really need to create any nodes or do anything we're just going to go to the details panel and here we can just tweak some uh settings so the wheel radius we're going to be uh changing this later on if we need to but I think should be fine right now wheel mass and you can obviously play around with these settings uh if you want the most realistic experience what you can do is you can just search for the wheel mass of the actual card that you're um using so yeah you can just do that so the front wheels the front wheels are going to be affected by brake affected by handbrake affected by engine okay those are going to be um setup and then it's also going to be affected by steering as well okay so the wheel angle um let's just set it to 50 right now we can change it later if you want but yeah so that should be it and for the rear what we're going to do affected by handbrake engine and Brake but then this is obviously not going to be the rear wheels are not going to be affected by steering okay so we're going to have to do that and I think everything else should be fine you can obviously play around with these settings if you want but for now I think we should be good to go okay last thing to do before we can actually like test this vehicle is the physics asset so the physics asset what we going to be doing is that we it does come with some Physics uh uh some um Collision Mees measures by default but we're going to be deleting all those so just go to settings and I think you have supposed to go to all Bones Show all bones and then you can just select all these all these and just delete them okay so now we can just uncheck this again so uh actually no I think should be fine we can just uh leave this on but yeah so so for the front left I'm just going to be adding a collision let me just make this full screen so I'm just going to go down to the tools uh to the tool and the Primitive life should be Sphere for the wheels and let's add bodies and now you're going to see that it's just going to add a collision to them so for the wheels I'm going to do a sphere and for the body I'm going to do something else which I'm going to tell you in a bit so sphere again add bodies so these are basically the Collision meshes that we're adding and for the rear right also a sphere and then for the rear left now this part is relatively easy you're just going to add collision meeses and let's go to the root now and for this instead of if you do sphere of course you're going to see that it's going to be very unrealistic cuz obviously the car is not rolling around right the car has to have like a proper Collision shape cuz we are going to have it collide with like different objects different obstacles and stuff like that so the Primitive type I'm just going to set it to single convex H this is just going to give give us a more accurate um Collision we can also set it to multic convex hell but that's going to be more um intensive on our computer but actually let me just go ahead and do that let's see what that does so I think we should be good um let's see how single convex H looks yeah it's basically the same thing yeah but if you want like a very um uh yeah usually multic convex is more what do you call it accurate than single convexo but in our situation it should be both are the same and it should be perfectly fine just go ahead and save it and let's cross it out okay so next up what we're going to be doing is that we're going to go back to the blueprint class and we're going to have to set up uh the what do you call it the engine so we're done with the wheels but we're going to go down and now we're going to go down to engine setup so we what we get is basically we get a a torque curve so if you double click this it's going to open up and so what we're going to be doing is that we're just going to be creating a curve uh to the maximum torque now basically you can just Google the maximum torque for your car but I'm just going to go to I think I did something like five something around 500 so I'm just going to be clicking uh I'm going to be control clicking actually no um it's shift clicking yeah my bad oops my bad um once again so let me just select this and delete it so something like that I don't know where the zero point is okay so we're just going to be starting from here and I'm kind of lost in this curve uh in this graph but okay so now what we're going to be doing is that we're going to be starting from here just uh shift click right here and then you can just create a whole um curve actually I think I went a little above what do you call it 500 so I'm just going to be bringing my points down yeah you just need to like create a curve [Music] and now what exactly this does you're going to have to experiment with that um um cuz so this is basically how fast I think this is how fast your um car gains speed so you can like control that uh I think this curve could be a little more steep something like that I think something like that should be good yeah that seems to be decent so basically when you accelerate the car it's going to gain speed like this it's going to gain more speed in the beginning and less speed as it uh goes up to the maximum um acceleration maximum speed okay so um now also the Max RPM I think this controls your uh speed so if you increase it to something like 7,000 now you're going to now your speed is going to be a lot more but I'm not going to increase it right now I'm just going to be setting it to 4500 right now uh so that we can I can show you the difference later on when we um are making you know the car faster cuz that's something which I really struggled with when I was first making this game um because I couldn't figure out what was the like how do you accelerate the car um more and how do you increase the top speed but yeah again the mass okay so the mass is pretty important because this is going to control the stability of your car so if you know anything about cars you're going to know that the heavier your car is the slower it's going to go and also um the more stable it's going to be and also another uh major thing which is going to control your stability is this Center of mass thing so if you click the center of mass override and if you decrease the these values is going to uh greatly affect how your car handles how your car turns how your car takes Corners that's going to be greatly affected by this I'm not going to be turning this on right now cuz we are going to do a whole part of this course which is going to be dedicated to you know uh teaching you the game mechanics teaching you the car mechanics of funreal engine and we're going to be experimenting with these values in just a bit but let me just get the car up and running first and then we're going to we're going to go ahead and do all that so let's compile this everything should be fine um now what we're going to be doing is that we're going to actually go ahead and create a game mode and then we're going to create a player start as well so I think we already do have a player start in this uh game um but what I'm going to do is that I'm just going to find the player start where is it okay it's right there so that's perfectly fine we can just go to the player start and we can start the game from here but right now if I just um click play you're going to see that it's not actually loading up our car it's actually loading up this car which is um set the default what do you call it default player okay so what you can do you have uh so what I'm going to do is that I'm just going to be going ahead and creating a new game mode so I'm just going to go to the game asset folder right click this and just create a new folder called game mode so we're going to go ahead and create a game mode so we're just going to right click this and we're going to go to blueprint class and then just game mode base select that and I'm just going to call this car game mode perfect so now we have this whole new game mode and let me just make sure to save everything save selected so this game mode is basically where pretty much all of our like most of our game code is going to be uh it's basically the blueprint class which is going to um sort of control your whole game and it's going to like run your whole game uh but right now what we're using this for is simply just go inside it and just go to the default Bond class and make sure to set this to car BP this is the blueprint class that we are using basically it's our car right so we have that and right now if I still if I still go ahead and press play you're going to see that we're still not seeing that so what's the matter with this the problem with this is that right now this game mode is not being used in order to use this game mode we're just going to go to world settings game mode override and just select our own game mode uh car game mode perfect alternatively you can also go up here and just select the game mode like this okay so you can just use this to actually this is already uh set but if it wasn't it's just going to give you an option to set the game mode but now if I go ahead and play you can see see that we have this car okay but right now we can't move it we can't basically we can do nothing cuz we haven't set up the controls for anything yet all right so let's go ahead and set up the controls first and for that we're going to have to go back to the car BP so in this what we're going to do is that we're firstly going to be uh setting up the functionality to control um the the basically the camera to pan around the car all right so the code is basically going to be something like this so we're going to be we're going to be dragging in the spring arm so basically the spring arm is what we're trying to control right and what exactly what we trying to do with this spring arm if I go back to my viewport you're going to see that all we're trying to do is that we're trying to rotate this right we're trying to rotate this in different angles I'm just going to do this make sure that it's not done yeah um so so we're going to go back to the event graph and what what exactly we're trying to do is we're trying to add rotation to this right so I'm just going to be dragging off of this and we can just go to we can just search add relative rotation right cuz what we're trying to do is we're just trying to add um basically we're just trying to take this rotation like the the actual rotation value and we're just trying to add rotation um yeah we're just that's exactly what we're doing so I'm trying to explain why we're why we're doing exactly what we're doing um but yeah so now what we're going to be doing is that we're just going to be um adding an event which is going to be Mouse x axis okay Mouse events Mouse X so this is what what this is is that basically it's going to be triggered whenever we move our Mouse in the x-axis and this is going to trigger this event right cuz um basically what exctly we're doing is that we're just trying to map out the mouse x-axis to the z-axis of the spring arm because the spring arm is going to be rotated in the z-axis right cuz let me show you an example so if I just click Global when we move our Mouse in the y- axis we want the camera to rotate like this right and that is basically the z-axis rotation so that's exactly what we're trying to do so right now it's this whole um rotation is basically just one component so we're just going to right click this and we're going to click split struct pin this is going to split it into like three different values of the X Y and Z rotation and we're just going to plug the axis value of this into the Z rotation of this now I do understand this this this is a little complicated to understand if you don't understand it fully right now that's perfectly fine I I I honestly didn't understand it the first time when I did it um but yeah eventually you are going to get used to this and it is going to be perfectly fine so what we're doing is that we're just using the x-axis to control the rotation but now we're also going to be needing uh to rotate it in another axis using the mouse Y axis right so I'm just going to be adding this again add relative rotation and then um right click this stru pin and then we are just going to be right clicking and adding a mouse y effect oops Mouse y event okay so we're just going to be plugging this in and this so let's figure out what axis we're trying to rotate it in right so if we if we move our Mouse in the Y Mouse in the y- axis we want to rotate it in the y axis right like like this so let's go ahead and plug this into the Y AIS perfect let's compile this and let's actually test if this is actually working or not so if I play this you're going to see that if I move my mouse you're going to see that it's perfectly fine and it's moving around the car perfect we still can't drive any or anything like that and the car for some reason is floating on top of the floating in the air so we're going to have to fix that as well but that's not a problem but yeah congratulations you just made yourself um you just made yourself like a moving camera and that's pretty good okay so next up we're going to figure out why the car is moving uh is is floating in the air so for that what we can do first is that we can maybe go ahead and uh yeah we can go ahead and try to reduce the wheel radius let's reduce it to something like 16 just to make sure that this is not the problem I'm pretty sure it's not but like it might be so we're just trying to make sure that this is not the problem okay that is not perfect so so we're just going to go ahead and undo this and set it back to 32 I think the problem is with collisions with our skeletal with our physics asset so or actually uh the problem is not with this I just realized what the problem is so what we're doing right now is for the physics to actually work you're going to have to check um an option which is basically simulate physics which we haven't done yet which I forgot to do so we're just going to go back to the vehicle movement component just search for physics and then actually was it in this yeah it's in uh the mesh okay it's in the mesh search for physics and just make sure that simulate physics is turned on so we we have all the settings ready but the problem is that we weren't like simulating the physics so now we're simulating physics and now it's perfectly fine now our tires are slightly above the ground which is going to um be fixed by reducing the wheel radius so what I'm going to do is that I'm going to be going to the front wheel let's set it to something like 28 let's see how that does so I'm just going to be bringing it down and let's play the game let's see how it looks so the problem is still there oh okay yeah I think it's a lot less so I think something like 26 might be fine 26 should be fine yeah 26 is perfect and for the back we're going to do something like 28 or actually 30 RAR BP let's do 30 and let's see how this looks yeah now now they're both perfectly flushed in the ground like they're they're perfectly resting on the ground so that's perfectly fine now let's add the movement part of uh the car how how exactly can we like make the car move after that we're going to be making the tires rotate and after that we're going to be moving to the most interesting part in my opinion which is the texturing because that's when we actually make this carard look a lot realistic a lot more realistic and then we can like start building the world around it and stuff like that all right so before we actually like um make the movement part of the car we're just going to go to file and actually edit and project settings and then we can just add some controls which we are going to be using to basically move the car right so we're going to need to add controls in here so we're going to go down to input so we're going to use action mappings and access mappings to you know um add controls to this so first let's add um an access mapping which is going to be um I'm just going to call this throttle throttle so this is this is going to be um basic basically the force which is going to move the car ahead and so the mouse uh the the key which we're going to be assigning to this is going to be W if you are by the way if you using um a a controller as well actually let me just connect my controller so I can like show you how to like add controls from the controller as well cuz I'm sure a lot of you will be making games which uh can be operated by controllers as well so let me just go ahead and control connect my controller real [Music] quick okay so I just connected my controller and so what did what I'm going to do is that I'm just going to beess pressing this plus button right here so it's going to be W and another key okay so if I click this button right here and if I press the right trigger on my key on my um what do you call it on my controller you're going to see that it's automatically going to detect that and so that's exactly what we're trying to do and if I go down if I actually press plus and add another one there's going to be break so I'm just going to add keyboard mapping to this for break I'm going to do s and another one which is going to be the right trigger oops right sorry left trigger so I'm just going to press that and that's going to be added right here so that's that's actually the benefit of you doing this otherwise you can just create uh nodes for the W key or like whatever um inside the blueprint but like the benefit of adding the the input controls here is so that you can add multiple controls for the same um same action okay and then we're going to be adding steering so string underscore right and so then we're going to be adding steering and in this what we're going to be doing is that we're going to be adding two controls different two different controls for a scale of positive and negative so the positive one is going to be right so if I press D on my keyboard there going to be positive one and if I press uh a this should be negative 1 because obviously we're trying to move into in the opposite directions right so that's what we're trying to do okay uh and we can also add the console um the the controller option of this as well so D turning left turning right should be um actually I think we don't need to like add two of those yeah I think we should be good with like one of those so yeah that's perfectly fine because with the controller it's automatically it's going to detect if it's like a positive value or negative value that's perfectly fine so I think we should be done with this and now we can what we can do is we can just go ahead and just cross this out so we can just cross this out right here and we can go back to the car BP p and just maximize this and oops my bad I'm just going to be clicking these buttons right here to like you know make these smaller and okay so now what I'm going to do is that I'm actually just going to be doing like a separate whole separate thing and so what what we're going to be doing is that we're actually going to be tracking in the vehicle movement component and to this we can basically uh search for throttle so set throttle input and we can also search for what do you call it set breake input and then we can also do set steering input so that's exactly what we're trying to change right we're trying to change the throttle break and then staring and now we can just plug the respective values respective um control mappings oops my bad draw mappings to uh all these so if I go to input access events you're going to see that this is the event which we added in Project settings right now so we're just going to be plugging that into the throttle input and the break one we're just going to be clicking break and then access events just set it to break and that should be fine and steering again we're just going to be searching for steering and so once we're added all these we're also going to be adding the AIS values into all of these as well CU obviously these are the actual values which are going to be passed on right so let's try to run it and let's see if the car is moving or not so the car is moving but right now you're going to see that it's very unstable and but yeah it's basically getting the job done and yeah but we we have a lot of work to do on the car uh it's the tars are not moving and like but yeah the car is at least moving so that's perfectly fine so now I'm just going to be Crossing this out and let's clck click save all and contrl S so I think we are basically done with the movement part of the car now we can actually go ahead and make the tires rotate and then we're going to be working on the physics of the car and like making the car actually fun to drive all right so to animate the wheels it's actually a pretty simple process we just need to enable the animation and that has a few steps but like um we don't really like need to do any hard work so what we're going to be doing is that we're going to be right clicking the skeleton and we're going to be going to create an animation blueprint so we need this animation blueprint for uh in order for the car to rotate the tires and so I think that should be fine okay so now what we can do is we can just go ahead and open the car animation blueprint so we're going to have to go to class settings and we're going to have to change the parent class to vehicle vehicle animation instance now this is basically what we're trying to do is we're trying to access the animations right so we're setting the class um which has all the animations as the parent class of this class so if you know anything about programming you know that the functions and the events and everything they are transferred from one class to another if the first class is the parent of the second class right so that's essentially what we're trying to do it's not only that like that needed like knowing this knowledge but like it's just better to you know know what exactly you're doing so what we're going to do right now is that we're just going to be be searching for a function uh which is basically a a control which is inside this parent class uh and it's called wheel controller for wheel vehicle I know it's a pretty weird name but yeah and we're just going to plug this in and it's going to um basically add this extra node for us we don't really need to understand what exactly this does I honestly don't understand what it does as well it's just that we're trying to access an animation from this parent class and we're going to apply this to the animation uh this car right here and so we're going to be doing one last thing which is going to be we're going to be adding mesh space reference pose now this thing again you don't need to know how this works or what this does just know that we're trying to an we're trying to copy an animation from a parent class and applying it to our mesh okay just click compile and we I think we should be good to go let's actually go ahead and try to see if it works it doesn't the reason for that is because we haven't actually set uh we actually haven't connected this animation blueprint to this blueprint class so we're just going to go to the blueprint let's go to mesh and let's go to animation actually the animation is right here and so if I extend this you're going to see animation mode is I use animation blueprint which is perfectly fine however the animation class is going to be set to our animation class which we just created portion i1 anim blueprint compile this and we should be good to go now you're going to see that the tires are rotating perfect that's very good and you can see the animation of the tires is like very realistic and very good and they're perfectly you know matched to the actual movement of the car which is perfectly fine but again the problem with the car is that the suspension is like super you know it it feels like a proper SUV however it's supposed to be a sports car so we're going to have to fix the uh fix the physics of the car and we're going to have to make some tweaks to it but honestly this part is like super interesting for me because you get to play around with like different physics uh things and it's actually pretty interesting to learn all that all right so let's actually begin with that all right so let's start to tweak the car and and so firstly what we're going to be doing is that we're going to be addressing the fact that this car is um also one thing which I'm noticing right now is that the tire is the front tire is a little um flushed in the ground so what I'm going to do is I'm going to go out of that wheel front BP I'm just going to set this back to 30 cuz the reason why we had to set it to a higher value before was cuz it was it seemed as it was it was off the ground but it wasn't so both of them should have the same height the same um radius so what I'm going to do now is that I'm just going to go to car BP and what we're going to be addressing first is the fact that the car is basically um the car is wobbling a lot like when we you know go forward and go back the car is wobbling a lot that's what we're going to address so for that what I'm going to do is I'm actually going to go to the internet and I'm going to search for Porsche 911 wait let's see how much it weighs so it weighs around 3,000 so three th000 pounds to kilograms so that's around 1360 all right so I'm just going to go to this and let's actually go to the vehicle movement component and go down to um where's the mass the mass let's set it to 1350 or actually something like 1500 should be fine the only thing which we need to do is we need to um enable Center of mass override and this is basically the X Y and Z values of this so Z I'm going to be setting it to -20 something like2 let's try it out so you know this should help with it so you know um you can see that it is somewhat helping with it but like it's still pretty big the issue is still pretty evident so what we can do is we can set it to maybe something like -50 50 should be fine let's see how it looks as you can see now it's it's like a lot more you know the car is a lot more realistic and yeah let me actually reduce it even further something like 60 should be fine cuz you know porsa uh this this Porsche is a pretty um like this car is pretty low and it's supposed to be like a very fast sports car so we don't really want it to you know um have a lot of wobble and the trans uh the the what do you call it the suspension should be pretty hard cuz it's supposed to be a car it's it's a car made for the track right so track cars usually have very tight suspensions so let's do that and apart from that if you want to increase the friction of the ground and let me actually show you why why you would want to do that so we can if we you know if you go ahead and if we turn also by the way when you turn the camera looks a little weird so we're going to fix that as well so if we turn you're going to see that the car is turning pretty slow like you know we we can't really actually you know what let's go ahead and add a handbrake too so that we can like actually break uh actually um what do you call it we can do some drifting as well so let's go to edit project settings and go down to input and then actually a handbreak is going to be an action mapping CU you know um with all of these we need the scale value we need to modify value but like handbreak is either on or it's off right so it's like we don't really need a scale value for that so I'm just going to call this hand break the action mapping let's set it to the space bar that should be fine and now we can go back to the event graph and in here what we can do is we can just drag from the vehicle component a vehicle movement component and we can just set this to uh set handbreak input so basically in this what we have to do is we have to toggle this on and off so the way we do that is by right click and let's do handbrake so this is the action event that which we just created so if it's pressed it's going to it's going to basically um trigger this event which is going to have the handbrake on and let's actually just go ahead and duplicate this so I'm just going to hold alt actually no not hold alt I'm just going to press contrl C and then contrl V duplicate this and then if it's released it's going to trigger this event right here which is not going to have the handbreak turned on I hope that makes sense it's just basic logic which you um I am assuming that you know like the very BAS basics of um programming uh in uh like just just the basics of programming in general so if you know them you should understand how this works so there's an issue with this okay so the problem is that the vehicle movement component should be Target of this as well so just do that and now if we move forward and we press space It should just break just do it's just just do the handbreak all right let's see if we can sort of break uh sort of um drift so you know we can like do a little bit of drifting but it's not really the car isn't that fast isn't fast enough to you know break uh to drift I don't know why I keep saying break instead of Drift But yeah uh let me just search for RPM of what do you call it Porsche 911 let's see so the RPM is around 9,000 okay so right now our RPM is literally half of that that's why the car is feel pretty slow so let me just go to the vehicle component movement component component and Max RPM let's set it to 9,000 cuz I'm trying to make this like a very realistic car okay now you're going to see that the car is going to feel a lot faster I can already feel the difference that you know now I feel like you know pull a little bit of hand break you are going to notice that we can drift a little bit of course not that like you know yeah this this this was a pretty good drift we're not going to be adding like very Advanced drifting uh physics but I think this should be fine for us all right so let's get out of the car and let's see what else to work on so I think our car is looking pretty decent it's feeling pretty hard the the uh what do you call the suspension is feeling pretty stiff as it should cuz it's a sports car of course you're going to have to modify this based on your car if it's like an off-road car if it's an SUV if you're I don't know if you're Mak maybe adding like a G wagon the suspension is going to have to be a lot more loose and the car should have like some wubble but again that comes down to uh basically your knowledge of cars and I would recommend you watching some like YouTube videos on like how cars work and how the physics of cars work and uh yeah just do something like that but yeah let let me make sure that our spring arm looks uh so right now you're going to see that if I play the car uh play the game and you know I can move this camera but if I turn it's very stiffly it's it's basically just locked onto the car that's not something we want we want the camera to have a little bit of lag a little bit of um you know delay uh between the car and the camera which is going to make it look a lot more smoother so for that we're going to go down to the spring arm we're going to go down to lag and then enable camera lag and enable rotation lag so the camera legs right now let me just actually show you what the default settings do so that then we can understand why we're making the change that we're making so right now you're going to see that the camera lag is making the the car go ahead and the turn is adding some sorry the camera rotation lag is adding some lag to the rotation so I usually don't like uh adding camera lag I just like adding rotation lag cuz I think that just looks a lot better in my opinion so now you're going to see that I turn it feels a lot more natural and it feels like a proper racing game right and now it feels a like a lot more fun to drive as well okay that's perfectly fine so we're done with that as well now what we can go ahead and do is we can maybe start texturing the card which is honestly my favorite part
Info
Channel: Nafay 3D
Views: 106,969
Rating: undefined out of 5
Keywords:
Id: gfleby2BLGo
Channel Id: undefined
Length: 61min 2sec (3662 seconds)
Published: Tue Dec 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.