I Made an RTS Game with Unity DOTS + ECS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
oh boy do I have an exciting video for you today because today I'm going to be recreating one of my favorite custom games from Starcraft 2 using unity's entity component system and of course when we're looking at unity's entity component system it works very well when we're trying to simulate large numbers of entities we can look at games like diplomacy is not an option which is a real-time strategy game or even city builders like this game called ixion both these games were made using unity's data oriented technology stack and their SD component system to process these large numbers of entities so I thought it would be a fun idea for me to kind of dip my toes into the RTS development just a little bit and create one of my favorite custom games from Starcraft 2. now to give you a little bit of a back story I was never really that good at the main game of Starcraft 2 but when my friends and I would play we often play these custom games there was this one custom game in particular that we played quite often called Nexus Wars so basically the way that Nexus Wars works is it's a four versus four Team Battle where each team is set up on one side of the map now each team basically has a base that they're trying to protect which is called the Nexus Now each player basically has their own unit they can control and this unit has the ability to build different structures now once a structure is built it's going to spawn units of a specific type based off of a timer now you as the player don't need to control these units at all once the units spawn they're just going to go ahead and path find their way to the opponent's Nexus and try to destroy it however because this is a real-time head-to-head game units from the opposing team are going to making their way towards your base and you're gonna have to fight them in the middle so it becomes this really cool kind of like tug of war Battle almost where you're basically you know trying to come up with a strategy of what types of units to spawn that might counter some of their units and of course they're trying to counter your counter and then the game basically goes back and forth until eventually one person just gets overwhelmed and their base gets destroyed so in today's video I'm going to be recreating Nexus Wars as turbo Wars built with unity's entity component system but with just a little extra twist because I'm not going to be making this game entirely on my own I'm going to have a little bit of help from the unity asset store so in today's video I'm going to be using 12 assets off the unity asset store to make this game look and play awesome I should also mention that today's video is sponsored by the unity asset store Who provided me with some of the assets in this video that I did not already own so thank you very much to Unity for sponsoring today's video now the unity asset store is hosting their summer sale right now and this is a really exciting sale because many creators like myself got to hand select the assets that are going to be a part of the sale now the assets that I've picked are going to be on sale from August 9th through August 17th again many of them are going to be featured in today's video so go ahead and check the links in the description if you want to go ahead and check out any of these assets that I've been talking about today so let's go ahead and fire up a new project and figure out what turbo Wars is going to look like so I'm actually going to start off this project by using an asset that I use pretty much at the start of every single project that I start and this is the grid box prototype materials now this is a completely free asset on the unity asset store it works extremely well with Pro Builder you basically get these nice grid boxes which is really great for blocking out levels and figuring out the relative sizing of kind of the main things in there so I kind of use this to start figuring out how my overall level is going to look before I start adding in some actual assets so then I started to kind of figure out the general art style of my game and I chose to use this awesome pack from cinti Studios called polygon sci-fi worlds now centi Studios is one of my favorite asset store developers because they create these awesome low poly models that you know even though they are low poly they look fantastic in game and they have tons of little details and just fun little things about them so anyways this sci-fi worlds pack is just a really great pack for an RTS Style game because it provides you with a ton of assets for characters buildings Vehicles environments and so much more so I thought this would be a perfect game to kind of Base my whole visual style around so at the beginning I don't really need all too much I'm basically just going to create some platforms for the main bases and then have kind of your main sort of Nexus as this sort of reactor building here so once again I have the general things blocked out I'm going to go ahead and start adding in some gameplay so the first thing that I'm going to do is add in kind of the base building mechanic where we can basically spawn different buildings into the world and then those buildings are going to actually spawn units based on a timer so first thing that I'm going to do is essentially create a grid system for the player to choose to wear to build their different units on so this whole grid system is actually built out using Unity mono behaviors just because it's really easy to do with unity mono behaviors and there's nothing necessarily like performance critical happening at this point and there's no reason for these things to actually be entities because we can basically just you know spawn game objects and keep track of the kind of Spawn position and be able to spawn ECS entities from that spawn position whenever we want to now for the grid system I started off by just drawing some debug lines using the built-in Unity apis for these different grids but I quickly switch those goes out for the shapes vector graphics from the excellent asset shapes this is another excellent asset because it allows you to easily draw Vector shapes in real time in your game environments and of course these look much more professional we can have nice rounded corners and be able to play with the colors a little bit more so I think it looks really excellent in this game and as you'll see later on in this video it's extremely useful for doing other things just like drawing debug lines and again it's much more easier to use and feature filled than unity's built-in debug line drawing so I would highly recommend this asset for any project that you're creating so at this point I have kind of a little bit of a building system in place where we can basically drop buildings on and they're just kind of spawning units however as you can see these units are basically just kind of flying across to the other base right now so let's actually go ahead and Implement some path finding here so I'm going to be using the agents navigation package again I am such a huge fan of this package I did a full deep dive video on this a couple of weeks ago and I think it is a really excellent asset it's just really easy to use I was able to to get this set up in just a couple of minutes for this project and it basically just allows these entities to pathfind their way to the opposing base very very easily and here's a little peek about kind of how I did this I actually have a separate kind of layer of everything for the actual pathfinding plane so then that way you know I can kind of swap out the visuals for better looking things later I can kind of still keep my base pathfinding planes you'll see that I actually do have two separate lanes that kind of have a Top Lane and a bottom Lane so they we can kind of have these like two different you know top and bottom Lanes doing their different battles of tug of war kind of similar to how the Nexus Wars works so anyways let's go ahead and address the elephant in the room of course we have all these units running around in t-pos right now and that's not exactly what we want out of our final polished looking game so yes I am actually going to go ahead and Implement some ECS based animations in our project using the excellent asset the GPU ECS animation Baker so basically the way this works is you have to go through a little bit of a setup process to kind of line up all your animations and everything like that and then you actually just hit a button and it actually bakes all the animations into a texture so I'm gonna actually show you this is what the texture looks like right now for the actual baked animations and this texture is basically sampled by the GPU to basically modify all the different vertices to play different animations so actually in this texture right here there's three different animations that can be played but anyways now that we have that up and running I now have these units basically just Naruto running from one side to the other and it looks hilarious and I was having just a ton of fun playing around with this we can now have mobs and mobs of entities doing all kinds of crazy animations so that was definitely a fun thing to play with so the next thing to do is actually add in some battling so we have enemies on both sides of the screen now we want them to when they intersect start battling with each other so for this project I've just decided to use unity's built-in dots physics system but I do want to give a shout out to another asset from the unity asset store which is the Gimme dots geometry asset this is a really cool asset because it gives you some some octri and KD tree type things for a very fast and efficient searching it seems to actually be set up more for working well with game objects rather than ECS based entities I was playing around with it a little bit on the ECS side and didn't unfortunately didn't get it to quite work the way that I wanted to so I ended up just using the regular dots physics system because I already knew how to use that already but I was very impressed with what they were showcasing for all the game object based sample projects that they provided so I would highly recommend looking into that if you're using a game object based game or you want to do any of their features that the Gimme dots geometry offers because there are quite a bit of other things that it offers so basically for my implementation I used the overlap AABB which is the access align bounding box to just do a quick search for enemies within a specific radius to see if there are any you know enemies within there if there are then they're actually going to start kind of pathfinding to each other and you can see as I was going through the debug process I was again using the shapes asset to just draw lines between the different enemies so I knew which ones were kind of properly detecting each other and make sure that we're not detecting units on the same team or anything like that so again another shout out to the shapes asset very helpful to use for things like this so now as I'm going through the process of actually implementing these battle mechanics I found it a little bit annoying to have to kind of you know scroll my camera all the way from one side to the other side to just you know spawn units to just kind of have them attack and make sure that they're you know able to interact with each other in the way that I want them to so I ended up using another asset which is the Adaptive split screen asset this is a really interesting asset because it's really actually kind of geared more towards local couch Co-op type play where if you have kind of a split screen type game you can kind of have players and they if they kind of go to different places in the map the screen just splits out and it always gives the player a nice good view about you know what they're able to see in relation to the level and everything like that and then if the players kind of come together the kind of camera Windows kind of converge into one so it is a really interesting asset for kind of things like that how however I was actually able to adapt it to this type of game where I can basically just kind of split the screen down the middle and I was able to look at one base on one side and one base on the other side then I kind of set up my own little camera controller was able to basically independently move these cameras around and again it's really cool that you can see how as I'm moving things around you can see that the screw the split screen is kind of changing and so it was really fun to play with I will say that there are just a couple limitations that I know the developer has plans to address at some point for instance one of them is that the cameras can only be rotated about the x-axis so you can basically kind of only tilt the camera down you actually can't tilt the camera side to side or do any camera roll or anything like that I guess it's just not supported right now so because of that I actually had to basically rotate my entire scene at 90 degrees so now that you know I didn't have to have any rotations on my camera's y-axis so once I got that all sorted out everything worked pretty well but there were just a kind of a couple little quirks with this asset so now as I'm building out the battle system of course want it to be a little bit more interesting so I kind of continued to use the GPU ECS animation Baker to add in more animations so now that not only can these entities run they can actually have little attack animations and things like that so I was able to add in this attack animation and kind of sync it up with the timing of it shooting out of projectile and then after that I kind of want to add a little bit of an effect so when the projectile actually hits an enemy that a little explosion effect plays this is able to use the next asset patch which is the Epic tune FX pack which is another again long time favorite of mine because it's just a really easy way that we can add in these cool tune effects that I think go really well with this low poly type style so the way that I actually have this set up is I'm using a manage data component which is kind of similar to a regular ECS data component except it uses a class rather than a struct and then I have this attached to the projectile game object now basically when the projectile game object detects its Collision it's just going to go ahead ahead and spawn whatever game object is stored in that managed data component so in this case I just have regular prefab references to the Epic tune effects game objects so I can just go ahead and spawn those into the world whenever I want to then after that I have to add in just a silly little death animation this animation is actually called a kick to the groin and I thought it actually worked kind of well for a death animation so I just did that and then just kind of have the basically entities sync down below the map and then just kind of despawn after that so now we kind of have the player versus player battle interactions happening exactly how we want it now we need to step it up a notch and we're going to actually go ahead and destroy the enemy's base now because this is kind of the main point of the game where we're trying to destroy the enemy's base I think I want this to be a really awesome and epic so I think it would be really cool to maybe have the bass break up into a bunch of pieces and kind of explode out and we can have a bunch of explosion effects coming out of that so I'm actually going to be using a couple of assets to accomplish this so first I'm going to be using the dots mesh slicer and the dots plus asset so the whole idea behind the Dodge dots mesh slicer is that we can use it to basically just slice up this one mesh that I got again from the cinti Sci-Fi worlds pack and break it up into little chunks they can kind of you know explode out into all different directions now in order to use that we do also need to use the dots plus asset so that's what I'm kind of including both of these here together in order to actually slice up that geometry kind of how we want it to the dust plus asset is just a really great asset to have for any dos developers anyways because it provides a lot of Handy math functions as well as just other utilities that are really helpful to use so anyways just using those two assets I kind of just you know split the bass up into a bunch of different pieces and added an explosion Force at the bottom to kind of make them all explode out after that however it still maybe just needed a little bit more so I just went you know totally overboard with some epic tune effects now we have this you know awesome animation or the whole base just kind of has this really cool explosion and then all sorts of fireworks play after that and those fireworks basically just continue on forever until you restart the game so I'm just had a ton of fun with this one so now that we kind of have all the core pieces in place now it's time to basically just finish this up so after this I want to go ahead and add in a little bit of unit variety so I'm just going to again continue using the cinti Sci-Fi worlds pack to create different Vehicles so I have like a hovering vehicle that again uses the agent's navigation package to do its pathfinding and everything like that to the opposing base and of course it's going to battle entities in the same kind of way the next asset I used was the flock box asset this is another dots powered asset I was basically able to use this to kind of create these little drones that kind of you know flock around and they can kind of you know move around and they end up running into different enemy units and kind of dealing damage to them that way so this was kind of another fun asset to use and then just add a little bit more character unit variety I added in some monsters from the infinity PBR low poly monster pack number two this pack includes a total of 19 badass low quality assets that you can use in any game then finish out the visual polish of the game I of course continued to use the cinti Sci-Fi worlds pack to add in a bunch more props and environment assets even added in another asset from front of the channel Tobias which is this fake Interiors asset this is a really interesting one because it basically gives us these kind of you know City buildings type look and we actually get this little bit of Parallax effect in the actual buildings themselves to make it look like those are actually real Interiors inside the buildings however this is actually all done through a Shader and it's actually just completely math based about how that kind of Parallax effect works but I think it looks really cool when it has a nice colorful and fun interesting background to this turbo Wars game so anyways Here's the final result of Turbo Wars again it is based off of the Starcraft 2 custom game called Nexus Wars which I was very much a fan of back in the day and I'm really happy with how this turned out I think it's a fun little game of course if you want to check it out you can go ahead and check it out in the links in the description below I will warn you that I don't have any enemy AI or anything like that set up so you actually are just going to be having to you know control both sides of the battle but you know that's okay for now and once again thank you to the unity asset store for sponsoring today's video again I've included links to all the assets that I featured in today's video down in the description below so don't forget to check those out and just a reminder make sure you go ahead and check out the summer sale because many of these assets as well as many more are going to be a part of this summer sale we can get nice steep discounts on all these assets so go ahead and check that out and again thank you to Unity for sponsoring today's video anyways with that I hope you enjoyed today's video and maybe it inspired you to make an RTS game of your own really do hope that you enjoyed this video again please let me know if you do have any questions or if there's any other videos that you want to see me do maybe there's some types of games that you want to see me create with unity's ECS definitely love to hear that down in the comment section below anyways I hope you have a fantastic rest of your day and I'll see you in the next one
Info
Channel: Turbo Makes Games
Views: 22,927
Rating: undefined out of 5
Keywords: game development, how to make video games, making games quickly and effectively, turbo makes games, johnny turbo game development, home cooked games, unity3d, game design, video game programming, game development for beginners asdf, game development for beginners, how to use unity
Id: mrHfQfhhJe4
Channel Id: undefined
Length: 16min 56sec (1016 seconds)
Published: Wed Aug 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.