Render 8 Direction Animated Sprites in Blender with Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everybody this is joe fizzle cc and today i'm going to be sharing with you some tricks that i've been learning inside of blender on how to quickly render out lots of different sprite sheets for your 2d game it's going to save you a ton of time if you're making any sort of four direction or eight direction players or enemies and it's definitely something worth investigating for you inside of your games if that's the direction that you're gonna go it's something that i'm actually using inside of the game that i'm working on right now which is called smash smash is actually a top down twin stick shooter mostly based off of smash tv or inspired by i'm collaborating on it with let's talk game design so you can actually go over to his channel link down below in the description and check out some of the devlogs that he's been doing already on that game with that out of the way let's go ahead and jump on in and see what sort of things we're working with okay so we're actually inside of the preview of our current version of smash i'm going to tease just a few things here most of this has already been shown inside of uh let's talk game designs devlog there's a few new updates here that we're we're testing out but um this should paint the picture for you that we've got eight direction sprite sheet on the main character you can see that he can have every 45 degrees there's a animation for running or idle or his really really cool slide which i absolutely love and we also are using some of those tricks on the enemies now we've chose a certain artistic style but you can really play with that artistic style inside a blender which is one of the really really cool things about going this direction so with that said now you get an idea of what we're going to try to be creating here let's go and see how we did it inside of blender but not before i blow these guys up all right let's close that out so we're actually going to use mixamo.com to demonstrate how we did this um we're going to use the mutant model uh which you can go and pick out a different character and you can play all these animations and miximo literally has thousands of animations which will save you a stupid amount of time highly recommend taking a look at it you can upload your own models use their auto rigger and then re-download it with the animation applied so in this case if you were to come down and select this creature npc pack and hit download you would get a zipped folder with all these different fbx files which includes the animations as well as the mesh of the mutant you'll notice though that he's not staying in place in all his animations and in this example i'm going to do the run idle and dying just to demonstrate how to render these out when you go to the run by itself though it gives you this option to check in place and that's actually super helpful so that you don't have to worry about that inside of blender and trying to move your camera with the character so download the run separately as well and check this in place and it will make it easier for you okay once you've done that you should have a folder with these fbx files in it so we're going to use blender now to open up both the mesh as well as the animations in a separate blender file and we're going to append those animations to the mesh and then render it out that sounds kind of complicated but let me walk you through it okay first things first i have a little bit of a starting template file already i just have the camera already pointing where i want it to point so i'm gonna go ahead and do file import fbx and let's go to the mesh which is right here and hit import you'll see right away that we get our cool looking dude and a t-pose which is great but it's not animated yet so we have to take those other fbx files which has the animation data and actually apply it to this mesh and i'll show you a quick trick on how to do that so go ahead and open up another blender instance and delete the cube and let's go ahead and import those other fbx files import fbx navigate to where you saved it and then we're going to import like i said dying idle and run let's go ahead and hit import and you'll see here that it's imported the bones without the mesh and it's got this animation on uh going on if i scrub the timeline down here i know i'm kind of in the way but you can see here that it's actually animating it so what we need to do now is save this out and then we're going to append it to the other blend file so let's go ahead and hit file save as let's call it mutant animation so i already did this once so hit save you'll notice though that if you come into the armature inside the scene collection that the animations have really bad names so this one is dying so let's go ahead and rename this to dying because it's going to make our life easier if you go to the next one i think this is idle yeah that's idle okay so let's rename this to idle and then let's go to the next one and by process of elimination this is going to be run all right so we have idle dying and run so let's go ahead and hit save again and then navigate back to our other blend file where we have our character so we're going to do an append now this is kind of where the magic happens hit file append let's go ahead and i've already navigated to it hit your mutant animations.blend to depend go to your actions and select the animations that you would like to add into this blend file so go ahead and hit append and now if you navigate over to your dope sheet and select your action editor you'll be able to actually apply each animation to your armature so make sure your armature is applied and select the animation from right here that you would like to apply let's start with dyeing now you can see okay so it's working great now one quick trick that you want to make sure you remember is make sure to hit this little shield here which is the fake user that way if you save your blend file and then reopen it it's still there otherwise you'll have to re-import it each time so go ahead and hit this and then push down and that's actually going to push it down onto the nla track of the armature so what we're gonna do is we're gonna select each of our animations and we're gonna do the same thing so let's go ahead and hit the shield which is fake user push down and then let's go to the last one which is run hit the shield which is fake user and push down so we have our armature with three animations on it dying idle and run great so if i were to go ahead and hit f12 right now which is the shortcut for render this is what it would look like all right that's kind of cool i have it fairly low resolution i have it at 256 by 256. you can control your render output properties underneath um this render properties tab and you can see up here you can select all sorts of different things there's a lot of really cool artistic stuff that you can do here that i'm not going to cover we do that inside of our game there's different shaders there's different things that you can do in compositing that you can do using cycles and you can get really really creative and add your own unique flavor and if you're using acid packs i heavily recommend you figuring out how to make it all cohesive like we were doing by using your own style and we're using blender's work flow to do that using shaders and compositing so that all of our rendered views have kind of that same look and feel so we're not going to go into that today but know that there's a lot of things that you can play with here um the other thing to note is that i could underneath this output here go in and select my resolution and change it i could set my frame start and end i could say how often i want the step do i want to be every frame or every other frame would be two and i could select my output folder and i could hit you know not just f12 but go ahead and hit render animation control f12 and it would render out to the folder that you selected the whole animation and you're good you've got it but we want to show you how you can quickly do it for four direction in eight direction and that's going to take a script now blender lets you script with python which is super cool and i'm going to share this with you in a download on itch so you can copy and paste it into your own blend file now there's a lot of different tutorials already out there and content online on how to do scripting but i'm going to give this to you as a template that you can use for your own projects all you have to do in here is select the armature that has the animations on it and hit run and it will output every eight directions every action into its own separated folders and then you can just dump it into your game engine which saves tons of time so i've already run this and i'm just going to show you what it kind of looks like so you can see here when i ran it each one of these folders i have my run animation i have east north northeast that select northeast you can see that i rendered out the whole run cycle of the player or sorry of the creature or the mutant or whatever and i have all these organized and nice clean folders and the script did all this for you and so rather than going through and like manipulating the armature to turn 45 degrees and then hit run animation and render out it again this is doing all that for you it organizes all of it and inside of the script i'll give you a quick walkthrough now that you know what it's doing there's three areas that you have to pay attention to so after you've selected where the the actions are stored which is on this armature you have to make sure that you can add or subtract the names of the animations that you want so you can keep adding it say you had something called like attack one you'd put that right there and make sure that everything that you want to have rendered you include there if you don't want something you can use control forward slash and it will comment it out right so make sure that you have everything listed here that you want it to process and then this is where you can control which angles you want so say you don't want eight directions say you only want you know four directions well it would be 0 90 180 and 270. and if you comment out those other four it's only going to render these four angles which is east north west west and south that's simple enough and then the last thing you have to do is you have to make sure that you add the output folder so put something on your hard drive i called mine mutant on my temp folder and that's where it dumped everything now once you've done all that you can hit the select this hit the run and it will start um the other thing i will tell you is you noticed that there was probably a lot of frames inside of my run animation maybe that's too many it might be too memory intensive inside of this script if you want to you can change it to be instead of every uh one i was playing with it you can actually change this to be every other which would be two or every third which would be three or every fourth which would be four if you do that hit run you can go ahead i think this will actually overwrite most of my things i'm gonna go ahead and delete this out and you can guys can kind of see it run let me delete all these 2 323 frames all right we're going to do every fourth which is just to make it go fast and to demonstrate it so let's hit run it will start running we should see yep so create a dying folder i already worked through these so now it's much fewer uh animation frames and that will help you on your memory and you can dial in exactly what you want and that is the magic of using this script in blender to quickly process some pretty awesome characters so it's already done um it only processed four directions because i toggled off those other four right so it went east north southwest so now you can go and whenever you make an update to your model say you didn't like the color and you wanted to adjust the hue you can do that and re-run it and re-dump it into your engine and you're good to go all right everybody hopefully that was useful for you check out the download link below to be on itch for the script and also thank you to all my patreon subscribers and supporters if you like this video please consider subscribing or giving me a thumbs up it's free for you to do and it makes a big difference for me also uh keep looking out for more updates on smash i think it's gonna be an awesome game really looking forward to collaborating with let's talk game design it's already been a blast and i'm sure we're gonna have lots of great content to come so with that said everybody have a great day and i'll talk to you all soon
Info
Channel: FoozleCC
Views: 19,488
Rating: undefined out of 5
Keywords: blender, python, render animation, 8 direction, 4 direction, sprite, spritesheet, 3D to 2D, mixamo, SMASH, S.M.A.S.H., Construct 3
Id: l1Io7fLYV4o
Channel Id: undefined
Length: 12min 31sec (751 seconds)
Published: Mon Apr 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.