3D Physics! // Hazel Engine Dev Log

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys my name is deterno welcome back to another hazel devlog and happy new year it's uh 13th of january it's like halfway through the month i finally dragged myself out of bed finally here making another video for you guys it's been it's been rough coming back from holidays is always like the worst but i do have some extremely exciting news today this is going to be one entertaining devlog hopefully because the features are just they're just flying into hazel but this time it's not just me that you have to thank so over the last year really the community for hazel has really grown quite a lot and there are a lot of people interested in contributing to hazeldev which is amazing now whilst we're not quite hiring full-time engineers who work on hazel just yet some people have been extremely generous with their help on hazeldev and has gotten to the point where i've informed a little bit of like a hazel core team and we work on on hazel peter 1745 is the person to thank today i want to give a huge shout out to peter 1745 this is his username on discord i don't even know what his full name is he is the person who has made possible what we're about to look at today which is 3d physics and hazel that's right starting the year off with 3d physics pretty cool so hazel dev has had 2d physics for a while using box 2d something i added a few months ago but obviously it was it's it's desirable to have 3d physics and a 3d game engine because whilst 2d physics is nice and you know you can still run yourself in 3d but have 2d physics overall you probably want to have some kind of 3d physics solution now this is something that i was kind of putting off for a while because it wasn't strictly necessary i wanted to get kind of the fundamentals done and like 2d physics but then peter showed up and was like hey man i i want to slap phys x and video physx into hazel so can i do that and i was like absolutely so here we are today now one thing i want to point out is that um again me and peter have worked have worked quite a bit on this features there's been a lot of back and forth it's been really like like having a development team which i'm really grateful for because as a solo developer it's really nice when i get to speak to people but overall peter as if he needs more like cool points the reason why peter stands out to me is because i've i've had a lot of people from the community common and understandably you know contribute code that that isn't like that great or like you know it's fine for like an open source community because you know when you have the community contributing code this standard of code is typically lower than you would find in like a professional team understandably because experienced engineers are probably spending their time you know doing paid work but every now and then someone comes along and writes code and and and works on a feature at a professional level to the point where like if the person was actually employed by me as like a full-time engineer in hazel i would be satisfied with their work and i think peter is is one of one of one of those people the game engine series of hazel has always been something that like is more of an educational series i'm more okay with people kind of taking that and doing doing stuff to it that i maybe wouldn't necessarily agree with i still see myself as like the kind of technical director of that project but it's more of like a community involvement thing whereas hazeldev is kind of like my baby hazeldev is like my engine that i'm secretly making behind the scenes to to both know what to teach in the game engine series but then also to eventually you know develop my own games in and to serve as like an educational resource to people who want to go a little bit past the game engine series and get into the more serious stuff so because of that i'm way more picky with the kind of code that i end up accepting because in a lot of cases it just makes more sense for me to write the code because it's like my engine if that makes sense so anyway long story short peter has done some absolutely amazing work and we now have physx inside hazel now there are a lot a lot more things that i'm still working on like integrating with c-sharp scripting a little bit better and adding more features in general like you know nvidia physics is a huge library there's a lot of really nice examples out there it's very straightforward easy to use 3d physics library i think it's very powerful it's definitely the solution i would pick over something like bullet it's a really nice 3d physics library and it's definitely my top choice for hazel so what can we now do well i mean what can't we do i feel like with 3d physics inside hazel now you know we've got 2d physics we've got 3d physics we've got like you know a full editor where you can like move things around and enter play mode we've got c-sharp scripting like you could definitely put together some game in inside hazel and uh yeah we're going to do that i'm not going to talk too much about that in this video because of course i want to reserve this video for 3d physics but in the future very soon probably i'll be putting out a video talking about what my goals are for this year and making something is definitely one of my primary goals for this year because i think that hazel is definitely getting to the point where we can actually start driving hazel's features by having an actual project rather than still kind of messing around with the sandbox which is a really exciting stage to be in in the life of a game engine anyway without further ado i know you guys want to see the physics i want to show you like building a scene from the ground up adding some physics subjects kind of the whole workflow i've been refining the work for a little bit making sure everything works over the last couple days and uh yeah it's very exciting stuff now whilst it's it's kind of mostly i would say mostly working there's still a wide variety of like edge cases and like other optimization issues and stuff that we have to sort out so for now it's in a separate branch called physx inside the hazel dev repository for those of you who have access to that who are patrons you can uh you can clone the branch and take a look at it for yourself one of the coolest things about hazel dev i think is the rapid development of features i mean sure the features aren't like fully qa tested and production ready but i i think the pace at which we're able to kind of produce these features is really really cool and i think that the best feedback i receive from a lot of people who do have access to this stuff is just how as soon as they're done playing with one feature something else just comes up so that kind of stuff makes me really happy and that's something that i appreciate working on a small scale project like hazel rather than something else like some large game engine in the industry anyway let's finally take a look at the physics okay so i've got this fairly empty scene here all i've done is added a camera directional light and a skylight just so that we can actually see something so if i play the scene obviously we just have an empty scene let's go ahead and set up some 3d physics so if you right click and go to create i've added some more options here to be able to just quickly make things so that you don't have to add empty entities and then start adding a whole bunch of components so we have some meshes here but then we also have physics i'll walk you through the the kind of basic way to add physics stuff without just using the presets though so if we just spawn in like a little cube here's our little cube looks great let's scale it up a little bit so we can see it and then maybe let's uh duplicate the cube drag it down a bit and i'm going to make like a little floor plane out of it so i'll just maybe shrink it down that looks pretty good i think maybe let's move this cube up a bit make it smaller okay so now what i want to do is actually simulate some physics so if i hit the play button we of course just see the geometry as you would expect nothing too fancy let's see if we can make this cube fall and will crash onto the ground so if i click on the cube and i go add component i can add a rigid body now i'll set this to be dynamic because we want it to actually move not just for other bodies to collide with it there's a whole bunch of settings here and constraints and stuff like that that you can play around with as well and then i'll add a box collider so this box collider which shows up in green like this represents the actual physx collider so this is this is the part that's actually going to collide with things now you can resize it as you can see i can play around with these settings and it's possible to make something that doesn't align with the geometry but by default because this is a one meter cubed kind of cube so one by one by one meter and this is one by one by one they match up right and if you scale it up obviously or you play with the scale that's also going to match as well so let's set this back to uh well we don't have to have it like as a perfectly uniform cube but we've basically created an object with a box collider um also the shadows seem to disappear when i select things i forgot to fix that before the video that's awkward but anyway we'll keep going so if i select this and it only it only seems to happen when we select uh things with actual um you know collision geometry which is weird but anyway so if i select this um and i well first of all let's just hit play right so now it falls brilliant but let's make it collide with this so we'll go ahead and go to add components and then we'll add a rigid body we'll make it static though and then we'll also add a box collider so really all we need for these things are box cloud is we don't have to like deal with meshes and mesh colliders we'll explore that a little bit later today but for now this is really all we need if i hit play now our cube is here right and it collides amazing let's uh drag this up this is pretty cool i'm not gonna lie i would be i would act more amazed but i have been like working with this kind of stuff for like the last few weeks so to be honest i'm almost a little bit sick of it but anyway let's uh run this little simulation here looks pretty good there we go let's go ahead and add a new uh mesh or a new physics sphere so now we have the same thing but this is like an actual sphere let's drag it up scale it up maybe what i'll do is i'll actually come over here to the materials panel and i'll add something i'll add some albedo to this so if we go assets i don't know i'll just go to like meshes maybe we'll use the cerberus texture um also i'll check that as used and maybe i'll make it like plastic just so that we can actually see it roll um and so if i hit play here then the uh whoops we forgot to add a to make this dynamic and if we hit play here there we go so that was a bit uh not as fun as i thought it would be uh maybe let's try again it's just landing on that cube perfectly let's try a different angle yeah okay we can always add more spheres and have them collide with each other okay and then you can see the sphere is rolling okay so that is some basic 3d physics this of course is pretty cool but it can get a whole lot cooler if you actually have like some kind of world or some terrain that you want to collide with so let's quickly go into blender and i'm just going to make a brand new mesh here we'll make a new cube maybe i'll uh scale this up kind of like this and what i want to do with this is actually just make like some terrain honestly now let's make sure the scale isn't negative because that would be annoying uh let's drag this maybe down a little bit i'm gonna go into edit mode this isn't really a blender tutorial but what i'm gonna do is just basically tessellate this a lot i'm gonna make a whole bunch more vertices uh pretty much everywhere um on this kind of surface so that should be that should be okay and i'm just going to manipulate some of them by using like a little soft selection here which sometimes doesn't the shortcut doesn't work for some reason okay and now we're able to just kind of create some nice terrain right so i'll just uh maybe drag this up make some kind of hills here maybe i will make like in the middle i'll make like a little recessed kind of dip here and then maybe i'll even make some kind of uh river here or something it's almost like a little dip uh like a little platform that's just recessed there okay that should be enough let's make sure we shade this smooth uh and then if i really wanted to i'd probably go to the modifiers and add like a subdivision surface modifier maybe let's just do one we'll see what that looks like and then if we apply that i'm just kind of concerned okay that's not too bad so we have about about like 3866 vertices according to that so that should be okay because obviously with physics meshes you don't want to make them too detailed otherwise your performance will suffer that looks pretty good i almost liked it better without the subdivision but we'll keep that just to demonstrate a high quality mesh okay so i'll go file export fbx and then if we go ahead and go to our little physics demo folder that i prepared earlier let's go ahead and physics mesh this i'll set the scale to 0.01 just so that we convert to meters and i'll export the fbx okay so now let's let's kind of delete this thing and instead what we'll do is we'll add an empty mesh and then we'll go ahead and load that so if i go over here to our folder i'll load the fbx file here it is as you can see it looks completely wrong let's go back probably would have been a good idea to actually apply the transformation before i started messing with all the vertices but maybe we can save it if i go to wireframe and just recalculate the normals and there we go let's let's try and re-export that there we go real live for devlog and you can see me mess up let's go ahead and i already deleted it and add that empty mesh back in okay looks pretty good to me so um let's go ahead and uh maybe not make it um like a shiny plastic let's make it more rough and maybe i'll even make it a kind of green color just like that so that it's more of like a terrain color uh and then i can just go to add component and then uh well we'll add our rigid body but then we'll add a mesh collider instead of instead of a box collider so if i add a mesh collider this will actually generate a mesh collider with physx and you can see that it looks pretty good so now technically speaking if i was to like drag this yarn to this on to this mountain it should just roll off the mountain when i hit play and there you go right so we have an actual mesh collider let's go ahead and scale this up maybe a little bit and we can move this around so that our world gets larger i'm not sure if that'll be fully captured by the camera so maybe let's move the camera back a bit more maybe i'll set the field of view a little bit wider okay and there you can see our little physics simulation looking pretty good so let's make that roll off that mountain that looks good i think okay so that is an example of these mesh clients being used now it's not very difficult to then take this and obviously add like a little capsule collider and an actual fps camera so that we can actually move around this terrain and jump around and we'll collide with everything so that's probably something that i will in fact save for the next devlog but i think this should give you a pretty decent idea of the kind of stuff that is now possible okay so as i mentioned loads of stuff that we can still show here but that's going to be it for this video hope you guys enjoyed please let me know what you thought of this and what you thought of the workflow and just your general thoughts in the comment section below don't forget that you can help support the development of this as well as get access to everything that you've seen here today by going to patreon.com huge thank you to everyone who does help support the series we wouldn't be here without you hazel would not be at the stage that it is at if it wasn't for you guys and your support i think that where we've come so far even though to me this still still seems like the absolute beginning of a game engine it's really quite incredible and i think that we as a community have something to be proud of because i don't think a lot of people can can say that they've managed to build something like this and we have so i'm really really proud of this community and of all of you guys for all of your contributions and for even watching my videos and supporting and everything like that you know um i think i had a lot of time to reflect over the holidays of this kind of few weeks that i had off from making youtube videos and i really am so grateful for the community and to be in the position that i am i am in and i'm so so excited for the future because this is this is like honestly the absolute beginning my new year's resolution for this year is to work harder and hopefully i'm going to be able to prove that with hazel and with this channel and with everything that i do so strap yourselves in it's going to be a wild ride i'll see you guys next time [Music] goodbye [Music] you
Info
Channel: The Cherno
Views: 49,690
Rating: undefined out of 5
Keywords: thecherno, thechernoproject, cherno, c++, programming, gamedev, game development, learn c++, c++ tutorial, game engine, how to make a game engine, game engine series, 3d physics, physics, physx, real-time physics, collision, 3d collision
Id: oqTAHwwSA9I
Channel Id: undefined
Length: 16min 25sec (985 seconds)
Published: Wed Jan 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.