Build a Unity app and view player data with MongoDB Atlas (Webinar)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so welcome to this webinar we will get started and underway very shortly but in the meantime uh please use the chat in the sidebar to tell us who you are and where you come from and uh we'll get started in a couple of minutes hello from the Netherlands that's very close to where I'm from actually I'm originally from Germany greetings from Phoenix Malaysia great to see where everybody Tunes in so we're already all over the planet that's great I like that [Laughter] Finland Texas last couple of few in Texas United States you're gonna have to be more specific there now that's a big place London that's a close one very good we're in Ireland some of us at least Luxembourg Australian Manchester Egypt Luxembourg again Sweden Lots from India as usual always great to see Nigeria New Zealand yes late late for you lot over there or very early actually I should say right well what time is it in New Zealand over there for you Malaysia is not it's also pretty far away in terms of time zone so yeah so 12 a.m that's dedication thank you so much for spending that late time with us all right we're we're about two minutes in we've got 70 odd participants we get started very shortly about another 30 seconds or so if you've just joined do let us know where you are tuning in from in the in the chat great to hear from you more from the US more from India more from the UK Berlin Berlin Germany even though you don't really say that up there I grew up in the south so okay well look I think we've got 80 plus participants which are great to see I think we will get started right Dominic sounds about right excellent so you're all very welcome to another mongodb webinar this one um you have two hosts and also a bit of assistance from from Brandon and and Nia on the side as well too answering some of the questions uh this one is all about a Unity app the Dominic my colleague Dominic Frye on camera there as well too created and we use it to essentially illustrate the power of Atlas and the power of the connections that we have in our partner ecosystem in AWS and also what Atlas can do to help you visualize your data so we created this quirky little game that we are going to show you very shortly to show a really Nifty example of kind of how to generate data and how to visualize and work with that data as well too um so if you pop on to the next slide Dominic will do a bit of housekeeping first the webinar has been recorded and we will share it so thank you for all that have joined us so far if you've registered but you know for some reason or other you can't participate it will be shared with you on a link after it's done your music uh too many people on board to let you get access to your microphones so we have two ways to interact with us you can use the chat obviously for any comments but we're not really using the chat for questions and answers we do have a q a section where you can put in your questions in there throughout the live this webinar and we will try to Endeavor to answer those either live or within the Q a chat as well too so please keep your questions for whatever you see going on on the screen between myself and Dominic in the Q a section it allows us to moderate that and answer those much easier there too at the end we love love to know how we're getting on so there will be a short survey to undertake and we hope to get some good feedback to help us improve and create more of these webinars for our audience so they're the that's the housekeeping questions in the Q a general comments in the chat that's perfectly fine and and for those that haven't already do introduce yourselves let us know where you're tuning in from so we bump to the next slide we'll show you quickly what we're going to run through today uh we're going to shortly show you a small game demo what dominic built to show off the capabilities of Atlas we're going to look at the architecture overview how that's all pieced together and what services are talking to which other services as well too we'll illustrate the atlas features that we have been using in this demo and and then we're actually going to show you how we're piecing all of this together so Dominic will take over at that point essentially and show some of the key components of how all of this was built um and at the end then we're going to share the code and resources this is a a public repo that anyone can contribute to and we're more than happy to get your feedback on that as well too and we'll give you some links to learn more we have quite a number of assets associated with this Leaf steroids game that we're showing and we don't have enough time on this webinar to go into huge in-depth so we've done live streams and we've got repos and other things to share as well too but first let's show you what we're talking about what is this Leaf stroids thing how does it work um and what does it look like if you were to play it we use these at the mongodb events we have a number of mongodb dot local events and over 30 cities this year and so if you come to one of those it's most likely you'll get to play this game if you happen to be and we'll show you how to get to one of those events towards the end of the webinar as well too but Dominic why don't you switch over to the game itself and explain your way through that before we look at the architecture that's good first of all hello and welcome for me as well and what I'm going to show you first is the game itself that we're going to look into today that will set up locally so can play around with that for those of you who use Unity that might be also helpful started to just see how you can work with the connection from Unity to the game service but consider that just a black box so even if you're not a game developer it's it's just one kind of demo that we'll look at and it should be valuable for you as well even if you don't have any Unity experience so let me just get into the game here the first thing I'm going to do just very simple I have a list of players here I created a player already and that's also part of the repository I'll show you that in a moment I'm just going to choose my player here I'm going to use this one you're always trying to get yourself a better score and I just have to you know just too competitive I'm going to post the link in a moment as well again to the repository um as soon as I show that to you the game is rather simple uh it's just basically a top-down kind of shooter game where you can shoot some boxes collect some power ups um and there's also enemies floating around you'll see on the screen we've got a player name a certain amount of time that you have to move around here in the bottom left you'll see the score and the players for those booster most usually have around 60 seconds to play uh want to make sure there's as many players as as possible to to actually enjoy the demo but that's configurable and that's also something I'm going to show you later on the configuration for this game is coming from Atlas it's safe there and gets retrieved by the game in the beginning and by configuration I not only talk about the time I also talk about how the scoring Works how many bullets can I shoot how many points do I get for those pellets or boxes that I'm shooting basically everything that you can configure in your game you can persist in Atlas and then on the Fly retrieve to get your initial game configuration going um for the game to play so it's another five seconds here and what's gonna happen in the end then is whenever I'm done the score gets submitted to atlas and we will in the end look at how that is going to look like in our lesson we can actually do with it what kind of um yeah information we can get out of it and there's one tool we'll show you which is called charts which is going to show you how to visualize that that's one of the things we'll get into in a moment but first things first so this is the architecture and it's really just done as an illustration of of you know how things come together here so we create and treat the unity game as a black box as Dominic said up there and on the left hand side um and that talks back through a rest service on AWS ec2 and through the atlas driver back to Atlas and on the right hand side we have when we use this at an event users register they sign up they get their name so you saw Dominic pick his name from the list of players there that's how that's done it's used for the registration and it's also used for the leaderboard and to show the charts at the end of the day which we will illustrate how they're pulled together so we work with AWS using leveraging some of their services ec2 and also private Cloud which is the relationship between what we do in Atlas and the AWS instance as well and but we will do tell how all of this works anything else to add there I don't think so it seems like we can get started there okay so let's show a little bit of why we're using Atlas for those that are unfamiliar and maybe some of you are it's great to see so many people on board this webinar Atlas itself is our multi-region multi-cloud developer data platform and we use drivers to connect into Atlas and or and there's lots of other ways that you can connect but in this instance in this game we use a driver and you know we have drivers for 14 of the standard most commonly used languages you know C C sharp Java node python rust Swift go kotlin I might be leaving some out PHP Ruby typescript Etc as well too so regardless of what sort of developer you are or what sort of language you use we have a driver for you to connect to Atlas as well too we use some of our database our Atlas um developer platform functions and features one of them is atlas search we use that for finding the player nickname in the web UI you will see how we build Atlas charts uh the dashboard that we create at the end of the game as well too so we have enough time in this webinar to show off these but obviously on our developer data platform there is an awful lot more so for those of you not familiar with it do check that out so if you go to cloud.mongodb.com you'll get straight in there you can create a free account free forever and get started with a proof of concept or a minimal viable product anything that you want to test out on what we call our m0 tier it'll always be free and there's plenty of space and bandwidth and compute power there for you to get started and you can grow from there up a number of tiers or indeed we do serverless so if you're unsure of the use and you want to try and keep your costs low as possible we can spin up and spin down your instances as and when we need with Atlas server so definitely try and check that out as well too if you jump to the next slide then Dominic um just to show you what your appetite of what we're going to show you at the end of this we use Atlas charge which is baked into Atlas to visualize a user's gameplay and the game the unity game that Dominic's created creates data and that gets sent back and stored back in a collection back among dibi Atlas and we can use the power of Atlas charts to visualize that and this is incredibly powerful for game developers of course in this instance but pretty much anybody who wants to uh you know introspect their data and look at their data and see what's happening there as well too we've got a number of powerful tools directly in Atlas to show that you can visualize that data and then the next slide just to show you where Atlas comes in we Atlas is a database built in the document model it's a nosql database and so we work on the idiom the data that works together lives together or data that's accessed together lives together so we use Atlas to store a number of key documents associated with the game that Dominic built we have a gameplay recording which keeps track of everything that a player does in that game that allows us to build a heat map that you'll see later on of where the players went in the arena we store all the player details so that we can have them in our list and we can interact with them and you know they can come and play more and more and they can be part of the leaderboard and then as Dominic said at the start there where just before he was getting playing the game config itself is pulled directly from Atlas so we can set the you know the values associated associated with bullet damage and speed how quickly you can rotate how quickly you can move Etc as well too so super powerful and that all is pulled from our collections back on Atlas as well too but Dominic I think that's probably enough slideware right I think most of the people joining the stream want to get stuck in to see things happening so let's get started there that's definitely more than enough I'd say yeah let me just start by posting the link into the chat again just to make sure you got that and then I saw a couple of questions already that I just want to quickly address while we added um the unity we're using for this is uh 2021 so I'm not going to use the 2022 LTS in that case uh but you can upgrade for those of you using it you can just upgrade it and use a newer version it should work and there's nothing nothing specific to 2021 that's just the version I built it on and for the other two questions um regarding AWS that's just the way the game has been built initially so you're referring to the architecture here probably um the game is currently deployed on AWS by game I mean the rest service that is used for the game and the website you can use any other cloud provider as well so if you want to you can also use gcp and Azure any other provider really because this rest service here as we'll see in a second is just a python application a flask application and their website you'll see in a moment is a Blazer server application so it's rather generic and you can deploy that wherever you want to and we'll actually do that locally on on my machine here to show you how you would set it up locally on your computer as well so you're open to use whatever provider you want it's not anything that's provided specific as as of now and the other thing about the ping um and if you would want to use a local mongodb you could do that but you don't really have to because for games where the Ping is actually really important like first person shooters any kind of fast-pass games fast-paced games um I play a lot of valerian and Rocket League lately just to give you two examples uh where ping is certainly very important you would unlikely actually have a connection to the database the whole time and get and post data from into the database in an ongoing manner you most likely probably load the data that you need and keep that session open and the communication between your game client and your server is very unlikely done with the rest service is probably going to be something like a websocket or anything else that can actually guarantee that you have a rather fast and efficient connection so um that's that's what I was two questions but first of all let's get started I uh posted you the the link into um the chat that's the the repository for this demo the repository as if it's public and what you'll find in the repository are three parts that you saw on the architecture Slide the game client which is written in unity the game server which is the rest server that is deployed on the ec2 at the moment that's a python application and as I said the website is a is a Blazer server application so what I'm going to do first is I'm going to grab this because I'm going to show you the whole thing there is also a readme which is going to describe exactly what you have to do to set it up locally it's just a couple of steps that you have to take and we'll go through those steps now that's what I'm going to show you and in the meantime you can ask questions um around that and after that you should hopefully be able to set it up yourself run it locally and then play around and use it as a template get started with your own project so let me get that a bit smaller there was a question about uh from mohab about the flexibility to for a large number of players this is a demo that we made um you know essentially to show off the functions and features of atlas of course if you wanted to have you know we do have a huge amount of games companies using mongodb to serve as their back end as well too so it is possible to do that you wouldn't necessarily architect it in exactly the same way as we're doing this now this is a a small light demo you would perhaps go and build you know more of a bespoke game server is that correct Dominic yeah that there's nothing to add to that that's exactly what it is um it's it's a starting point um but first like I guess the most important part is not every game is the same so even if we were to create um an example for one specific type of game and and a big number of players that would still differ in terms of architecture depending on what kind of game You're Building um and specific for games that the requirements are just very very different and you have to adjust the like the architecture and how you build the whole thing depending on what kind of game You're Building uh I mean you know like there's so many different types of games right um there is just no one solution fits all uh kind of thing in that case yeah and I think the key thing there is that we do have a huge amount of gaming related customers running on mongodb for their data store for a whole load of different kind of uh use cases and uh so we we can do the scale most definitely just you know this demo is a demo exactly so what I've done the first part that I've done is I just checked out the repository into a new into a new folder um so just a fresh copy of the whole thing um just to reiterate on that the requirements are Python and the.net SDK that you need to have pre-installed and then the first thing before I'm actually gonna get into changing the code and adjust it to connect to Atlas is I'm going to show you how to actually um yeah create a new cluster if you haven't registered for Atlas before you'll find a link here behind uh create a new Atlas project which is going to take you to the sign up and after you've done that what you'll see basically is make that a bit smaller um you'll create a new organization and then you can create new projects which in my case obviously is empty for a start I'm going to create a new project I'm going to call this webinar life and the first thing you'll see here is adding members I don't need to add any additional members so I'm going to be added automatically as a project owner so that's fine we can start with that and that's basically what you will let me make that a little bit bigger so you can see easier that is your like default initial uh view onto your newly created project and the three services that we provide up here that's that's your project it's active and the three services the three pillars of others I'd like to say are our data services app services and charts we won't go into too much detail or actually not at all into app service today we'll focus on the other two parts the data services is um your data right your actual database and everything around that and charts as I mentioned earlier is the visualization of your data so you can actually see what's going on um in your game or um around your game let's start with that one first and I've written that down here for you as well so all you need is an m0 cluster and then we need to add some data to it so I'm going to come over here I'm going to build a new database one of the really nice features about Atlas and one that I really want to point out is the m0 that we're going to choose here which is all you need to get started to to test around is our forever free tier we get 500 megabytes of storage which for data is quite a lot as you might know um so that is a really good starting point and it's gonna be free so you can play around with that and create your application I can choose my provider where I want to host this on and similar to the question earlier I'm going to choose AWS just because I personally regularly work with that but you can also choose Azure um and Google Cloud as well of course as a region I just usually first of all choose the region that's closest to me because I'm going to deploy it locally and I want to be as close as possible Ireland is available in that list here I'm in Ireland so that's a good starting point you can choose a name I'm just going to leave it on the default here but that's going to be your cluster name and the cluster is the thing that's going to hold our databases later on so first of all I need to figure out which are cars though I think those are cars very good always send to test you you're pretty good at them at this stage yeah it's like I had to practice a lot lately so I got better I guess two of the security features um that are important obviously um to make sure not everyone can just like play with your data is I need to create a database user to actually log into my database I'm just going to call that webinar life as well my password it's the same for now and the other thing that you'll need is you need to specify which IPS are allowed to connect to this application your local IP that you're working on at the moment that Atlas automatically detected will be shown down here you can add other IPS especially if you deploy a server that's obviously not going to be your local IP you have to add that here if you don't know that as of now and you want to just add any IP to to get it tested you can do that for now by by using this cidr block notation here zero zero zero slash zero and then that's basically going to contain any IP that you want to to allow here but for now I'm just going to use my own IP my local one so only I can actually access this cluster and then I'm done what happened in the meantime in the background is and that's what you're gonna what you're gonna see here is a cluster got created a cluster is always per default the different ones but per default a replica set made out of three nodes so you already get an initial um initial set of safety here with having a primary and two secondary nodes that's what we call them um where your data is replicated and um yeah shared on those on those um on those three nodes now let me come back over here again and see what I have to do next is I need to create a database right so this one is going to call luceroids one of the things you'll see up here is cluster zero it's just the name that I left on default I can actually just click into that one and there's a couple of things I can do here I don't want to go into too much detail for most of them the the interesting part for now which is probably where it will work in in the beginning usually is your collections databases and collections on your cluster so I'm going to click on this one and now I can add my own data here what that means is I can Define my own database here I'm going to just create a database that we'll call esteroids and then I need to create a collection that is called config because our game needs an additional initial configuration right so this is the the collection name there are some additional preferences here not going to go too much into detail but you can read about them in the documentation a capped collection um it's referring to the size of the collection that's something I can configure here and then one of the things that will provide in the example um in the demo repository here is one example for how such a configuration should look like I'm just going to copy that whole thing because this is the default configuration that you just saw me playing and I can just insert documents right here in the UI which makes it quite handy for the initial testing I'm going to go over here to the Json view I'm just going to delete that whole thing and paste the document that I just grabbed from the repository and you'll see there's several configurations in here you already get automatically shown if that's a valid document or not you saw that just a moment ago and there was a red bar down here so if I insert that now we got a config collection and this is showing one configuration down here um and round duration is 60 rotate speed is 100 life span is is one all those can be changed you can add more once again in that case as well it's just an example so you can add as many configuration properties here as you want to it's completely up to you what you need for your game this is uh basically giving you a starting point I don't need this anymore the second one that I need to create is events because uh this whole thing is events based what you just saw me click here is next to the listerodes database there's a little plus icon to create another collection this time I'm going to create the events collection and the same thing here I got a template for the events there needs to be at least one event for this demo to make it work so I'm going to insert a document again over here this document is going to be a bit simpler and smaller we got the ID for this event is mongodb TV I suppose it's worth qualifying as to why we have this events configuration as well too is because we started this as demos at our mongodb own events and even some of our partners events too so you need to decide on Entry to the game what a venture participating in so we've got a leaderboard and the heat map for that game everything that you'll see in charts at the end if it wasn't for that we wouldn't necessarily have an events we just have a list of players exactly so that's um something that you'll see in a second because the event that I just created will show up as um in in the event list which in that case obviously is just one event but it'll show up in the event list um so that we can actually choose this event so that's actually everything we need to do for now in our in our cluster in our address and with it with that it's it's already set up there are a couple of smaller additional settings we need to put down for the game server and the website and then we're actually already um yeah ready to run that the first part I'm going to start with is the game server itself so I'm going to come over here to my console first which I want to make actually a bit wider make it a bit easier to read um if I look into this uh we see the same structure obviously because that's the GitHub repository that I just cloned um looks like a Windows VM running on Ubuntu no it's the other way around now it's not the other way around that's a it's a just a Ubuntu host that I'm using here it works the same way on Windows and Mac OS so the system that you're using should not influence they should not influence the demo itself um the the commands I put down here will work on on Ubuntu on Mac OS they should also work on Windows um you might have to adjust some of the things the way the the windows terminal works but that's about it it's other than that it's agnostic to a the whole system you're using so what I'm going to see here if I go into the game server the game server we got an environment file here dot end file most of you should probably be familiar with that um that is just where we Define the environment or any kind of Secrets or anything like that that we need to make the game work there is a template file here if I look into that template file I'll see there is really just one thing in there and that's what's mentioned over here is a connection string I'll explain that in a second what that is um that's the only property you need to configure to actually make the game server be able to connect to our freshly created Atlas and the way we do that is we're coming over here back to data services we mentioned earlier there is something called the drivers and the drivers are a library an SDK that enables you to actually connect to your Atlas cluster and it's basically just one piece of information that the drivers need and that is what we call a connection string which contains your credentials and it contains the um the URL or the identifier for for your cluster you can find that quite easily by coming over here click on connect and then you'll see there are certain different options there are also tools like Compass which is a really great desktop application to use and actually inspect your data and work with your data we also got the visual studio plugin and other options what I'm going to do here for now is I'm going to choose drivers because that's the way we connect to our application with our application to Atlas rather as Shane mentioned earlier there is a ton of different drivers by now for all the bigger languages depending on what you choose here we're going to show you how to actually install that and later on also if you want to show you a code example of how that will work I don't need that for now independent of what you choose here we'll find down here a connection string and that is what I just explained credentials and the cluster URL to tell your drivers or tell your application that is using the drivers where to actually find your cluster and how to log in so I'm going to copy that over and what I'm going to do now is I have to create an environment file by using the template I'm just going to copy that over the connection string in here is just a template so you see how that should look like just to make sure you grab the right thing from from Atlas I can delete that here and then insert the connection string just make sure to substitute the password here obviously otherwise that's not going to work and then save it in the end so that's the environment file for our game server for those of you familiar with python you'll know python you'll know what I'm doing here for those who are not familiar I'm just quickly going to go through it while I'm copying this over and let it run I'm going to create a what's called a virtual environment in Python um that's basically just a container you work in um for with your application and this is the way to to activate the virtual environment and then a set of requirements that need to be installed those are defined in Python in a requirements.txt file and one of the requirements is we use a library called G unicorn you can also use flask there are several other options that depends on what your like what your preference is and what kind of server you're implementing for this one we're going to use G unicorn and one of the informations will pass along apart from the lock level is which Port it should run on that's the important part so that we can actually in a second connect to it and then you can see starting Unicorn it's now listening on Port 8000. and uh yeah so there's one work active that's basically the default here if I click on this one what I should hopefully see is that my server is alive but you'll see in the uh the default application in the application file is the the default um or the base route is going to return just live because we do have several other routes here for example if I ask for the config now you'll see exactly the config that I just put down earlier and um in a moment we'll also see the players I'm going to show you that as a Next Step so we can actually now set up the website I'm going to leave this one open and running I'm gonna let me make this a bit bigger so you can actually see what I'm doing maybe one more all right that should do so now I'm gonna go back into the root repository that is as you can see also a folder called website and if you look into that you find all kinds of things as I said it's a place or server application um it's not super important that you're familiar with that because all we need to change here as well is the environment file and then just use.net to run the application so what I'm going to do here as well I'm going to copy over the environment template or rather actually I can just use let me first show you what I'm doing here so this one looks the same because the only thing that the website needs which also um if you remember this this one um the website also uses the drivers so the only information that the website needs once again is the connection string I'm going to make my life a bit easier because I created that file already just go into the game server dot end and copy that over here now we got the same environment file here so if I look at that I got my connection string in here and that's all you need to do the only other thing then I need to do is do.net run to build and run the application that's going to take a moment longer than the other one I was actually quicker than expected I don't like that right so sometimes sometimes the build of those.net applications takes a moment but I'm not going to complain about that one and now on my localhost port 5002 there is a website listening and what I'm gonna see here now is a player registration and login register and login down here you'll see the same event here which is just the default um event that I created a moment ago which is called mobile dbtv and I'm gonna just create a user called webinar life and register that so that's looking good for now you're gonna see that there is some information down here which is not filled out yet which makes sense because we haven't played yet that's one of the next things we want to do so I'm going to come back over here so the part will run the website is finished that's good now let me open another one here and I should probably change my defaults here to not make everyone wait but that's that's the way it is for now for the game client it's basically the same thing once again we need an environment file because you should never check in those environment files into your GitHub repository they contain SQL stick maintain credentials um so they're obviously not checked in the game client for those familiar with unity you know that there is an assets folder and then my prefabs my materials and all that the only important part and once again the same the same way I explained it before with the.net application you don't need to be familiar with unity um you only need to exchange the environment template you don't even need to install Unity itself if you want to use that specific demo but you're not a Unity developer I'm just going to quickly show you something over here even though I'm going to use Unity locally here to to show that for those who do not have Unity or do not want to use Unity or really just want to see what's happening behind that black box because that's what it's supposed to be you can click into the releases and the newest release is 2.12 and in that release you'll find pre-built versions for Linux Mac OS and windows and some instructions on where to put those environment files when you download the game because you still have to create the environment files and put it in there there's just a specific folder that you have to put it into I'm not going to go into do the details here I'm just going to use um and show you how to just do that in unity so we got the assets folder this is where my environment template is sitting and if I look into that that one is slightly different because in that case the game client is not supposed to connect to the database directly you would usually not want that you have a game server in between that enables the communication between the game client and your database but the thing that the um the game client needs to know obviously is where can I find my server right the default in here that's just to give you an idea how that environment file is supposed to look like the default in here is going to work for now because I'm deploying locally anyway and if you remember I started at my game server over here g j unicorn passing along the 8000 as a part which is exactly why I put those defaults in here to make it easier for you don't even have to change anything the only thing I need to do here is either move or copy it's up to you make sure that the environment file exists here as well that's exactly what Unity will then in a second use to um to start the game to connect to the to connect to the server so the thing that I want to do here now and that might be with small bear with me I can't actually make that bigger but I'm actually just gonna choose webinar life which is the repository that the name I chose locally for the repository and then just game client uh those using Unity will know that's all you have to do here webinar life and then I'm gonna open this one what I need to do on the side while this one is opening is oh no I already did that sorry I need to create a user what I would what I can show you in the meantime is what happened while I was creating that user like after I created that user we can now see a new collection two new collections right one step bigger two new collections actually that's correct one is players and that's exactly the player that I just created I gave it the nickname which is with webinar life team and email I just left the way they were which is empty so that's why I see a null here and then you get a location here which depends on the event that I created the background for that is um a bit more complex to talk about that today because it's about uh sharded clusters and how to actually properly set them up and one of the things they need for that is what's called a sharding key and the location is used for that as it's not something that we can go into in the limited time today but you'll also see that uh for yourself and the location here is identity to the location you defined in your events and every collection every document that's created in a collection also always has a property called underscore ID which uniquely identifies this document there's a second collection called players unique um this collection has been created to make accessing the data from this uh Global collection players easier and quicker but that's also an optimization that we'll have to go into at another point in time um that's a yeah a deeper topic about chartered clusters and how to optimize them for performance so I can make that a bit smaller again so this is my unity game the only thing I need to do here because it seems to not per default get selected is I'm gonna go to the Loading scene and that's all I have to do and then I can just started but let me do two things first make this one bigger and this one and then you can hopefully see that a bit better so that's what you're gonna what it's gonna look like when you started no matter if you use the unity client directly or the downloadable pre-built version that I just showed you that's in the end what you should see when you start the game we see the event that we just created which is obviously just one mongodb TV I can choose that um this is part of the the Boost demo that's why I'm gonna get the welcome to mongodb here so you can also see the um event name here as a basically as a reassurance okay it was loading the right event um never a bad thing and then the next step that I'll see here is select your player and since I've only created one player so far with the the website over here I'm only gonna see one player here I'm just going to start that one you'll get the introduction every single time but you can just press enter to skip over it I'm going to do that here for now to not make you watch the introduction again and the game is obviously going to look the same because the game hasn't changed the only thing that we've changed is as you can see in the top left is the player webinar live and we're now sending the data in the end to new cluster that we created there was a question which is probably a good time to ask this yeah when do we send the data Dominic from the plague is it during the play or after the play for this demo the the way this demo works first of all is a single player demo it's um one round after the the other and what's Happening Here is in in the beginning I load the players to show the player list I load the configuration when I before I start the game so that actually can start the game and the game itself records the information at the moment about what's happening which means the movement the the location that the player is in shots fired um boxes destroyed the information that we are interested in and in the end the moment the game over screen appears we send the whole thing as one blob to the back end depending on your type of game and I'm pretty sure the next question will be um how to avoid people cheating while sending that data depending on the type of game that's obviously not uh what you want for a simple demo that works quite well depending on what game it is you could still leave it that way in most cases you will very likely have a communication open as I said earlier it's most likely going to be a websocket connection um because they're rather fast which is what you want and you'll have those uh will you have that connection open and the communication between client and server is usually not that the client is telling the server I'm in this location the client is usually sending the information to the server I'm executing this or that in terms of their Direction change fire and whatnot and the server is then going to decide okay this is what's going to happen you're here and then it's going to send the location back otherwise the client would be able to just choose okay where am I what did I just kill what did I just shoot uh how many points did I get that's the decision that the server obviously needs to make um to avoid that uh to avoid that um the data gets um tempered with that's what I was looking for perfect so I'm gonna we've done a play now so we're gonna see hopefully the data from that play appear back exactly so there's two things we'll we'll see in a moment um I actually just one for heat for now here I'm gonna make this bigger again uh yet another collection has appeared here which is what I just mentioned as the one blob that gets written at the end of the game and that is a recording the same thing as with the config you can choose whatever you want to record here the things that we've chosen are first of all I need to know which player has played um the event that the player has played in is interesting for me in that case and then there's two things additionally apart from the date and time here obviously the the statistics how many bullets have been fired how much damage has been done how many pallets have been destroyed the most important part what's the score and that is just like basic statistics and then the other thing and I'll show you that in a second again and you saw it on a slide for a brief moment is we also want to know where was the player so we have snapshots of those positions and you can see there's always an X Y and Z coordinate and there's a lot of snapshots I'm just going to go down a bit further because those initial ones were probably just me sitting in the the center while I was still talking and explaining so if you go down here a little bit further you'll see that it could coordinates for the player moving and that can be interesting for like many different reasons it can be interesting to create a heat map which we'll look into in a moment it can be interesting to create what you might know from some games as a playback system so you can actually play back the whole game and see what's happened which I enjoy quite a lot actually because it helps you quite a lot to understand what you did in the game and what you could do better there's all kinds of information and opportunities you can take out of those of those snapshots and you can save additional data to for example also record where are the enemies that have been moving around um where were the locations for the boxes that have been shot it completely depends on what you need for your game and what you want to save and what you want to visualize later on because that's the interesting part and that is actually what I want to get into next are there any other questions from anyone no it's quite quiet at the moment I think we've answered questions I think just to bookmark for those who might be trying to keep up and see where we are at the moment in essence Dominic's gone through the creation of his project on Atlas and his clusters the ones that he needed and his documents at the beginning then we connected up the game to the website and then we connected the game actually back to mongodb with our connection string and in doing so and in playing the game creating a player playing the game it's created a couple more documents back in mongodb and so we still don't have any insights as to what that player did so now we're going to show you as Dominic said to be spent some time in the data services tab don't have time to go through the app services in this webinar and now we're going to show you how simple it is to take any data that you might have generated and Store back on Atlas and to view that in a visual way using Atlas charts exactly so first of all the charts tab up here you saw it yeah it took a moment to set up but what you see in the end is your dashboard your charts dashboard consists out of um your dashboards or like the the initial view consists of dashboards that's what I wanted to say there you go um you get one initial One automatically created that's Dominic's dashboard here and that's all I'm going to use for this demo to just quickly show you one or two things um in charts and how to set them up so I'm going to go into my dashboard inside the dashboard those little tiles that you saw earlier and that we'll create for now are referred to as a chart and the first thing we have to do is we actually have to select what kind of data do we want to show there is only one cluster active in this project so that's why this cluster is shown here in this cluster is just one database active and then we'll see all the collections that we just created the one that's interesting for us for now is obviously the recordings collection when you choose the recordings collection it's going to load the structure of the collection over here and charts is also right away giving you a couple of ideas of what you might or might not want to illustrate and show in your charts and I'm actually just going to start but the very first one here and I'm actually going to use that to show you what that means as I said the fields are down here over here is where I Define what I actually want to see the chart type up here in that case is a number you can see there's loads of different chart types and we look into one or two others in a moment but for now I just want to see some some number and the suggestion that charts made was let's just take the IDS and as the aggregate let's just look at how many distinct IDs are there so we've seen that earlier for a moment we click on browse collections again close that one and go to recordings as I mentioned for every new document that you create in a collection an underscore ID field is automatically generated with a unique ID so what we can do if we go to charts is check those IDs and aggregate them by saying give me the number of distinct IDs which in other words means the amount of rounds that have been played so I can come over here and give this one a title to make it more clear what it is number games played because that's exactly what this number is representing I'm going to click save and close and now I'm going to get one of those neat tiles that I can move around on my dashboard it's obviously not really super impressing for now we have to add only one on it but yeah yeah and it's only like a simple one so that's uh it's maybe not the most interesting one as soon as you started creating um some charts one other neat feature here is that charts is going to suggest you what kind of data um your data source you might want to use for your dashboard we want to use the recordings again and what we're going to do next is what probably most people would be interested in is a table and we will create a leaderboard a leaderboard obviously has to have the name of the player which is what we move over here into the groups so we group the table by the the um the player that has been played and then when I look into my session statistics down here we saw earlier there's a score and the values for the for that table makes sense to be set to score there's a couple of adjustments I want to make here and they also show you how super easy it is to configure that whole thing first of all I'm going to call this leaderboard and that is the highest score per player and that is also an important bit of information I mean if you read leaderboard you obviously assume it's the highest score but charts doesn't necessarily know what you want to show here and there's more loads of different um lots of different options that you can show here the default here is some that's obviously not what we want we want to always see the maximum score each player um has gotten now that looks good so far now one other nice thing about charts is that you can configure how this tile is going to look like number one is going to be as you can see down here there is a total for most tables that's probably what you want to sum up all the numbers here for a leaderboard it doesn't really make sense to sum up all the scores that all the players have gotten so we need to get rid of this one and then we can just quickly do one more thing for the fields I can actually overwrite them I only want this to be player and for the sessions I want this to be score needs a moment to load that's okay we've got a question just we might as well answer it live are the charts auto updating or point in time creation I know the answer Dominic perfect question for what I'm about to show you now because it's exactly the next thing that I wanted to show you so first of all let me check that again what did I do customize Fields player override that looks good this one looks good you don't have a table anymore where did it go yeah I think it's just a preview I'm going to show you that exact thing uh okay over here that's exactly what I wanted to show next um for this little refresh button here you got settings and the setting the default is that the dashboard refreshes once an hour depending on what kind of dashboard you have that might not be enough or it might even be too fast because the data doesn't change that much you can show it um just statically and on the refresh manually just the the quickest interval we got here um within those settings is one minute I'm just going to choose that but at any time you can also say give me your first refresh and now the data loads and I was just stuck for a second here um once again not super interesting but if I play another round or register another player um I would see more here and to not have to fill that manually I'm just gonna quickly as a last thing come over here and show you how that might look like and what you've seen on the slide before um before we wrap it up to to give you an idea of how powerful charts actually is so what I created over here games played um is is this one so I'm told we got 902 games played at the events that we've used the demo so far and we got a leaderboard over here where you can sort and see the scores of all the players that have participated in those demos so far and that can also give you an idea of what is like a typical score what is an average score or what is a weirdly high score where you just know okay that guy must have been a cheater figured out how to cheat his way to the top of the leaderboard that's what he did and he did it very successfully that's a that's a really good score here um and yeah and then a couple of other like neat features to see how many pellets destroyed and collected but one of my most favorite features probably the heat map which which shows you where our players usually which areas of the map do they go into and as you can see the center of this one is a little bit more red because most players tend to stay close to the center some Pirates are even completely white which means no player has ever been in that area and the outer parts are all in the same kind of yellow because some players go there but not all of them and then they just move around and the coverage is relatively the same but you can see some areas here where it's a bit more a bit more intense and that could give you a good idea um of Officer of those locations and the good thing about that and that's how I want to wrap it up uh is that what we said in the beginning is just the game itself is just a black box the kind of data you see here doesn't have anything to do with I mean it's based on a game but it doesn't necessarily have anything to do with the game charts can show you all kinds of numbers for any application that you might build it can show you any kind of activity so here you see like a Time based chart any kind of activity that you might um want to see how often is your application used at which Times by how many players or users and even the heat map it might not be a game it might actually be a position in in a store or an application that's used with GPS and people walking around so as you can see all of those all of that data that is actually put back into Atlas and can be visualized um is shown here in a game but it's it's universally usable and charged as a really really powerful tool to to visualize what's going on and be able to analyze your application and yeah make it better and and know what you use out there are doing so with that let me come back over here where were we we were here yeah exactly so thank you Dominic I mean to go through all of that content so swiftly I know that obviously there was pre-built things there but for anybody who wants to follow along or try this at home themselves if you go scan the Cure while it's on the screen or indeed in the chat earlier I put a link which is really easy to remember so mdb.link that's our shortcuts mdb.link forward slash Leaf steroids underscore links will take you to page on our mongodb developer Center where you have all of the links to the repos a previous live stream and the presentation Etc that we have all around this and as we said at the beginning this is something that we use at events uh Dominic put this together a while back we've reused it a number of times we're always trying to improve it so if you are a game developer or somebody in that space and you're happy to contribute and join in by all means too if you want to build out some more charts that we don't currently have by all means do as well too we'd love to hear from you if you can join us on that repo and create you know any PRS that you want the more the merrier we have a few more a couple of minutes left maybe if there's any other questions you want to jump in the chat or in the Q a I know we're going to open up a survey now as well too so I'm going to hand it over to Nia just to open out the survey and so we can get some feedback and to improve these webinars going forward yeah and just before we do that I just wanted to like you you mentioned the PRS but if you have any issues or any questions around the repository feel free to to contact us or me directly or but the most obvious way is it's just open issue in the repository ask your questions um and we'll happily help you out to get the whole demo running for you and get started using it and trying it out okay perfect Shane and uh Dominic for your amazing presentation now I'm going to drop this quick poll please let us know how today's webinar went with the amazing presentation from Shane and Dominic um but before we jump into q a and while you all are finishing filling out the poll I want to invite you to attend one of our DOT local events which might be coming to a city near you when you attend you will have the chance to meet with peers from this webinar with you along with experts like Dominic and Shane make sure to visit mongodb.com local to learn more when you register enter code webinar 50 to save 50 I will drop this link in the chat um I will hand this over to Brandon to read some of our poll questions I think there was uh just one more question in the Q a um Shannon dunk oh okay so we answered the charts about auto update and the next one is about security with unity Dominic that's your space any comments there yeah that's a good question I actually have to pass on that one um and the reason is quite simple I'm not a security expert in unity um and when we created the game with you and I mean of developed with unity before that's why I chose this one and not not others um but the focus was not on giving an example implementation for Unity specifically and that leads back to what we said earlier it's just meant to be a black box it's a fun playable Black Box um but it is a black box so the the unity implementation is really just to show you how to actually um connect to your cluster or connect to your not to connect your cluster sorry that's what the game server does connect to your game server um but it's not supposed to be a Unity specific example um or template implementation um like for a game that you actually create the the important bits where it's more an example implementation is the website and the game server and what we do on the atlas side so just give you a bit of an idea what the background behind that is um but unfortunately not an expert on that on that matter yeah I mean of course on the on the mongodb sides we we have encryption we've got query build encryption we've got a everything that you might possibly need from the security side of the the house I think you know we talked about game development companies using mongodb before we have an awful lot of financial institutions now on board using Atlas as their back end as well too and if anybody's worked in the financial space before you know how hard it is to convince those sort of Institutions to use anything on on the cloud and they're very much on premise I want to be near it I want to be able to see it I want to be able to touch it and we've done an amazing job our team in mongodb our engineering team in overcoming most of those hurdles that those financial institutions have with regards to storing data on the cloud with any of our Cloud Partners AWS gcp and azure okay great thanks guys really appreciate it um you give uh any last calls for questions um last chance to fill up the poll we really do appreciate you taking the time to uh give us your feedback let us know how we can improve uh what you enjoyed and we will um take that information and and apply it to our next sessions and hopefully see you in person dot local excellent and thanks everyone for filling in the poll I do very much would like to know who are the two people who think they can beat your high score Dominican Leaf's droids I'd certainly pick you up on that channel uh challenge um two brave souls have said they're very likely to beat your score I love that we should probably like do a do a challenge around that and people can send in a video of them actually playing that or if you have a chance come to one of our DOT locals where we show the demo that would be another option yeah well I know like you and I know that this Leaf storage demo has gone down really well at the events we have a a ton of enhancements planned for it as well too so watch this space because there will be an opportunity to compete uh in Leaf stroids in some way or fashion uh openly not just necessarily at the dot local events as well too what a tease and with that Mia you want to build this out do you want me to tease even more there's gonna be something I stuff coming up but the magic words yeah imagine letters I should say excellent news continue to fill out the poll everyone and if Dominique you can go to the next slide um did you know we got a podcast it's called mongodb podcast there's a lot of great content and speakers so check it out and have a listen we'll be sure to post the link in the chat if you haven't or send or tuned in and as well as listening don't forget to subscribe on whatever platform you grab your podcast from and also leave us a review please it really does help us to reach our audience as well too and um yeah please do that yes well thank you all so much for attending today's webinar um we invite you to reach out and look out for an email from us with the link for the recording with the email that you registered with thank you all again thank you Shane Dominique and Brandon for tuning in and please be sure to reach out and ask any questions um to us in the mongodb community forums as well I will drop that link in the chat too thanks everyone for joining have a good day good night Wherever You Are thanks everyone bye-bye thank you so much
Info
Channel: MongoDB
Views: 2,004
Rating: undefined out of 5
Keywords: mongodb data api, mongodb, mongodb atlas, nosql, nosql database, serverless, what is nosql, crud, database, databases, nosql tutorial for beginners, nosql tutorial, mongodb university, mdb, mongodb atlas database, how to use mongodb atlas, app development, mobile database, using mongodb, what is mongodb, serverless database, nosql databases, AWS, mysql, da
Id: C3qpSvxZKi8
Channel Id: undefined
Length: 67min 16sec (4036 seconds)
Published: Thu Jul 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.