Blender Godot gamedev tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello my name is Vitaly in this tutorial I will be using blender but it will be different this time we'll create a small 3d puzzle game great and powerful Google engine will help us with that this will be a remake of classic parking puzzle with slight twist we will start as usual with blender let's create a few rows of cars very simple in low poly we will have three different sizes of cars a few cubes will help us to stay in sizes let's start with smallest car the modeling technique is very simple you can follow alone or make your own design and don't forget that we are working lender internal [Music] apply a few simple materials one with color of your choice and other black for the glass [Music] [Music] let's add some wheels [Music] [Music] another simple material for the wheels [Music] we can use mirror modifier this time but we will have to correct a origin point [Music] a few last touches and we will say that a first car is ready [Music] in a similar manner will create more cars [Music] [Music] [Music] [Music] [Music] [Music] [Music] and lastly we will create a red sports car [Music] [Music] [Music] this will be enough modeling for now let's jump to the Godot and create a new project [Music] filled a project with key folders this theme will be our main add a spatial node as a route for the scene and rename it as main don't forget to save this scene [Music] in a models folder we will create a expert directory and use it as a expert destination for our models let's begin to expert we will use a petrol cloud exporter you can find it on Internet [Music] don't forget check only selected and don't forget to select what you are exporting [Music] as you can see I checked a few other options and add a name for the file [Music] before exporting the rest we will jump back to the Godot materials are imported automatically we just need to open our file as a new instance had a few changes to the materials and sales scene [Music] [Music] [Music] [Music] [Music] repeat this process for all the cars [Music] [Music] had a new spatial node it will be helpful later we can load levels to this point [Music] at a camera node turn the camera to look from top to bottom [Music] drag one of the cars to the scene and add a light source [Music] [Music] now we have a baseball game and we can try to run it [Music] gadot will ask us to select a main scene and we will do this with pleasure we can edit a game screen size in project settings now we can start work on a code [Music] attach a new screen to the main node as it is a 2-d game we will need to transform a screen cursor position to a 3d position for objects create a variable and assigned a camera node to this variable we will trace a ray from the camera position through the position of the cursor on the screen the collision point of this ray with a physical object will be a position that we are looking for so we need the plane that will be our floor we will create such plane as a static body at a Collider [Music] and set it as a plane shape for convenience we will move our static body to a fifth physical layer add a raycast node to the camera [Music] add a variable and assign this new node [Music] the array has to be long enough to reach our playing thousand units will be enough also we will have to know the screen position of the cursor Godot will present us this information create a vector variable that will point our array the camera class has a method for us this method takes a cursor position as the input and returns a vector to his direction let's multiply this vector by the length and conveyed the result to the raycast this is a good moment to force array to update his state to not rely on data from previous frame don't forget that the array should be also in a fifth layer let's test if there was a collision and print out the collision point if you don't see the output check if the plane and recast are on the same physical layer and if Ray is enabled to test this more let's move the car to the collision point as you can see it works correctly we will stir this as a variable and reach it from other parts of the code when we need it [Music] now we will go back to our car add a kinematic body to the scene this will be a base note for cars move car model to the kinematic body node add a Collider [Music] select a box shape and fit the size of Collider to the model [Music] [Music] add a new script to this structure [Music] the car must response to clicking-and-dragging input reputable option has to be checked connect the input signal to the script this function will receive a lot of input signals we are interested only in Mouse clicking [Music] this simple code structure will notify us about pushing as well as releasing buttons from now we will print some debug messages this will help me illustrate one problem we don't receive the signal when releasing was done outside the collider but it is easy to fix just check the input capture on drag third of the kinematic body and now it's working perfectly add a boolean variable to store this state [Music] add another variable that will point to the root node of the scene [Music] and now on each physical frame if car was pressed we will move car with mouse [Music] say the car has a separate sing [Music] method for movement that we are using has a drawback it doesn't count on collisions but it is also easy to fix instead of moving directly we will calculate the vector and push the car into his direction [Music] this vector is a difference between cursor position and position of the car [Music] we will use this vector as a input for the move and collide method and again a minor problem car jumps to the position of the cursor after clicking [Music] [Music] the fixed that we will save a difference between car and cursor position on click and use this shift as a upset [Music] [Music] now it's working bred for this game we have to limit movement with only one axis per object car have to move only forward and backward [Music] mask vector will help us with that [Music] after multiplying we will have zeros where there are zeros in the mask but what if you turn Carl 90 degree well then we have to turn masks the same way [Music] the first attribute of this method is a turning axis in our case this is y-axis second attribute is the angle this value will take from car rotation in this case we can have four different results we are not interested in negative values cut them off with absolute function it looks like we did a good job to be sure let's try with all four different directions that we need in game in the original game car are moving on this grid grid but I decided to move away from the grid instead this game will take into account of the accuracy of a player and it will punish for the crashes but before that let's do a simple optimization we need a physical process only when car is moving let's turn it off in all other cases add an area note in another box Collider we can even duplicate an existing one just don't forget to press make unique this Collider has to be a little lower to not to interfere with mouse pressing and a little wider to respond to collision first connect a body Android signal if it isn't self print the message about collision if there was a collision we will stop the car later we will add a sound meanwhile back to blender and create a few simple elements to build a scene from [Music] the scene will be built with mesh tiles I even will create a simple level in blender to see the ratio of objects [Music] [Music] on the perimeter there will be a curb [Music] [Music] [Music] [Music] so our level will be based on four elements and we will expert the same way as we did with cars one by one with ember there will be a difference this time we need only meshes that's why we will save each mesh in a separate file [Music] let's create a new scene in Godot at a spatial node and save the scene drag all four elements to the scene one by one the side curb must restrict the movement of the car that's why we will add a static body and a Collider and set the collider size when all is ready convert the scene as a mesh library add a grid map now to the main scene and choose a library that we are just created tweak a few options and start to draw a level selecting elements from the library and turning them with s [Music] [Music] we will need to detect a victory for that we will add an area note with a Collider again the box-shaped Collider is enough tweak the size and place it on the exit connect the signal to the main code [Music] if the area was closed by the object from the certain group we will print the message for now [Music] add one of the cars to this group and test this victory [Music] we can even hide the mouse cursor when car is moving [Music] and multiply the movement vector with number less than 1 this will add a feeling of inertia now based on this car and models that we have created we will prepare some more [Music] [Music] [Music] [Music] with those cars we can recreate some basic level add a sound for the moment of crash sounds I found and free sound org [Music] define a function per main node that will be called in event of crash add a call to this function in the appropriate place of the code this sound is in loop to fix that select this file and open the input tab uncheck the loop option [Music] I will add an image that I created in Inkscape it will appear on the screen after crash correct and logged position with anchors [Music] one additional line will show this image add a few more sons this time it will be in alarm [Music] [Music] [Music] it's great but alarm sound should be turned on a bit later we will add a timer for that [Music] [Music] a few small changes in the code [Music] [Music] and we have our result [Music] [Music] [Music] [Music] I will stop with this tutorial here thank you for your time you can extend this idea in any direction source code of this project with a few additional features is on github the link will be in the description have fun you [Music]
Info
Channel: Fun with Open Source
Views: 11,074
Rating: undefined out of 5
Keywords: 3d, blender, godot, game, dev, gamedev, puzzle
Id: tPiRq73uGO8
Channel Id: undefined
Length: 36min 55sec (2215 seconds)
Published: Sat Jun 30 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.