Programming Gymnastics and Restaurants!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome back to my journey of creating a city builder game from scratch using my own engine it's been a while i haven't made a video for quite a long time unfortunately i had some health issues again i had to have another operation but it's all sorted now all completely fine and i'm back making devlog videos again this video is going to have to be slightly different from usual i have been working on the game on and off over the last few months but i haven't really been filming much so i don't have footage all the way through the process like i usually do so this video is just going to have to be a kind of update video a bit of a summary of what i've been working on since the last video to get you up to speed on where the game's at at the moment and then things will hopefully go back to normal for the next devlog video so in the previous vlog i was just finishing up version 0.1 of the game and in that version you could place roads you could place buildings and then people would come to the town they'd travel around in their cars and just kind of walk aimlessly around the streets but they wouldn't actually do anything so the feature i wanted to work on next was an activity system so that the people could actually interact with the buildings that you place and go inside them and actually do things in the town like going to eat at a restaurant or sitting outside at a cafe so i got to work on that and the first step of getting a person to do an activity was getting them to the building where the activities going to take place and for that they needed to know where the building is or more specifically where the entrance of the building is and which road tile it's connected to so i worked on adding an address component to the buildings which holds all that relevant information and then when a person wants to go to a particular building they can just plug that address information into the travel system which i've shown you in a previous video and that will take them to the entrance of the building so for example i've told this guy here to go to the cafe and using the address and the travel system he can make his way there he's parked his car up nearby and then he'll walk all the way up to the entrance of the building ready for the next step and that next step was to allow people to move around on the tile of a building because up until now they've only been moving around using pathfinding on the roads network so this was slightly different and the way i decided to implement this was to add some nodes to the building tile points of interest places that the person might want to walk to and i also specified how these nodes are connected to each other and then using some very simple path finding the person can easily find his way from one node to any other node on the tile obviously there were still a few small movement issues at this stage the stopping was still very sudden and then when he starts moving he first sets off in whatever direction he's facing and most noticeably the way that he just walks straight through the door so i worked a bit on that smoothed out the stopping fixed the starting and i also added a new function to the movement code which allows me to tell an entity to go to a target stop at the target and then turn to face a certain direction so now when he walks to the table he turns to face the table when he gets there or when he goes to the menu he turns to face the menu to look like he's reading it so the people now move around the building tiles but they're still not doing anything so to get them to look like they're doing something i had to implement some basic animations so i set up a very simple animation system in the code which meant i could now tell any person to do any animation and i created a simple test animation to test it out and you can see the code for that animation here it's literally just using a sine wave to change the rotation and the height of the person over time and here's the result of that animation in the game using the new animation system i was then able to create a quick animation for entering and exiting doors and you can see the guy in the game using that to go in and out of the building here with a few obvious movement issues which i did eventually manage to tidy up i then wanted to test things out with a building that has more than one door and i didn't have any of those yet so i got into blender and i created a model of a small pub with a beer garden out the back [Music] and here it is in the game with one door at the front to get in and then another door around the back to get to the tables and that'll work quite well so at this stage i could get a person to travel to a building they could then move around the building area they could go in and out of the buildings using the doors and i could get them to do any animation i wanted so all the building blocks were in place for me to now go ahead and create the full-blown activity system and the first activity i wanted to make was going to a restaurant or a cafe where the person would arrive check the menu sit outside at one of the tables and then go inside at the end to pay to make the restaurant activity the game first needed to know which buildings are restaurants and it also needs to know things about the restaurants like where the tables are that people can sit at where the menu is and stuff like that so i had to implement a restaurant component which i could add to any building that i want to be a restaurant and i then just had to indicate which nodes are the seats which node is the menu and where do they go to pay at the end with that done i can now create the going to a restaurant activity and i did this using a behavior tree system which allows me to construct complex behaviors for the people from simple building blocks very similar to creating something like a flow chart for a behavior so it's like do this step then do this step then if this is true do this then do this step five times etc etc so i implemented the behavior tree system and then i implemented a simple behavior tree for the restaurant activity and you can see the steps of that activity in the code here and on the right you can see it happening in the game so first if there is a menu the guy goes to the menu and waits there for two seconds as if he's reading the menu he then goes inside and waits there for two seconds presumably asking for a table he then goes to the table and carries out an animation which would be like an eating animation or something then to finish up he goes back inside and waits there for two seconds uh presumably to pay and at the end he goes to the exit node and would then go on with the rest of his day i'll also just quickly show you one of these sub actions too so the go to weight action just looks like this two steps first go to a node using the movement system i talked about earlier and then wait and the code for weights is also extremely simple it's literally just a timer so all the individual blocks are really really basic but they can be put together to create some pretty cool complex behaviors at this stage i was becoming quite a big fan of behavior trees and i wanted to implement something similar for the animations in the game so that i could build complex animations from simple animated parts so i just kind of got rid of the old animation system and started using the behavior tree system to implement the animations as well and in order to try out some more complex animations i decided to get into the olympic spirit and create an outdoor gym with a few different pieces of equipment for the townspeople to train on and after a bit of work creating the animations the gym was up and running [Music] let me just quickly take you through some of the code used to create the animation for the parallel bars here you can see it's broken down into these steps thanks to the behavior tree and it starts with the person jumping onto the parallel bars it then loops the stepping animation eight times causing the person to walk along the parallel bars there's then a very short weight and it then starts looping the swinging animation three times and then to finish off it does a jumping off animation and even this is still a very simple animation i could add some conditional blocks for example to add more randomness into the animation so that the routine is a little bit different every time all the animation movement is done in the code of course so for example here's the code for the walking stepping part of the parallel bars routine and you might notice that there's almost no maths in here when i implemented animations like this in my previous game equinox there was always quite a bit of maths involved and the code got quite complex but this time i found a much better way of doing it and that is by using easing functions to manipulate the position and rotation of the person and i'm not going to go into detail about them here because that would be getting a bit too technical for the devlog video but if you're a game developer and you haven't heard of them then definitely look them up they're really useful for making movements and interpolation more interesting and they're very easy to use as you can see and the other parts of the animation are just the same as well so here's the swinging part which is just easing functions and here's the jumping off part which is also just easing functions so quick and easy to make no extra maths needed and yet once again these very simple building blocks can be used together to create something much more complex back in the game i added a staying at home activity so that a person could just go into their house sometimes rest in there for a bit before coming back out and then i finally filled the town with people again and just got them doing random activities around town and the town just feels so much more alive now there are people coming and going from houses traveling across town to exercise at the gym or sit outside at their local cafe the beer gardens are now also full of people it's just so much more dynamic and interesting now and of course this is still just the start these were some relatively simple examples of activities and i hope i'll be able to create some much more complicated ones in the future um one thing that i think will really make a difference is when i introduce objects and items that the people can interact with for example it would be nice to actually be able to see some plates of food and drinks here at the restaurants and maybe even have waiters bringing it to the tables i'm also going to be making use of the activity system soon by implementing jobs for the townspeople so that they go to work each day and then they'll also have hobbies and habits and certain activities that they'd like to do in their free time so slowly but surely the individual lives of the townspeople are going to start taking shape so that's going to be it for this video the devlogs should now be a bit more regular and i know i said that last time as well but well let's hope i'm right this time but anyway i hope you all have a fantastic week and i will see you all in the next video
Info
Channel: ThinMatrix
Views: 35,661
Rating: 4.9949694 out of 5
Keywords: devlog, indie game, city building, game, gamedev, game development, city builder, thinmatrix, opengl, java, sandbox, simulation, day in the life, indie developer, programming, game engine, roads, network, lwjgl, low poly, model, house, building, cars, traffic, indie game developer, art, low poly houses, low poly art, animations, ai
Id: VtdhP8sZCt0
Channel Id: undefined
Length: 10min 52sec (652 seconds)
Published: Mon Aug 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.