Ask a Dev | State Machine | Unreal Engine Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] [Music] [Music] all right everybody welcome back to another ask a Dev live stream this is the Unreal Engine blueprint tutorial q a basically answering all your questions about game development virtual production augment Rihanna virtual reality visual scripting uh blueprints and you know all the cool stuff my name is Kevin currently we're doing these twice a week uh the way it works is I we hang out we answer your questions and we also have a tutorial topic that we'll talk about in the background if you all don't have any questions so today's topic we're going to be talking about State machines that's our fallback topic for today I got a lot of really cool stuff to show you with State machines uh if we get to it pending you all's questions as I said my name's Kevin I currently work as a I have a job I swear to do I work as a senior principal Tech artist in r d at Riot games I get to do a lot of really cool stuff with Unreal Engine every day there's a lot of stuff that I get to learn by trying to help you guys out too so this is part of why we do that and as always I'm also always working on kind of my own things as well which is fun so with that we do actually have at least one question to start off with today Weston's chimed in in the chat and was asking about hit results so we're going to hop in and take a look at that let's see here we'll hop into unreal here and bring up our chats and get going now hang out because what we're going to try to do today in addition to uh you know getting through all of your questions and talking about State machines is we're also going to try to build a Crouch so if we get time we're gonna try to build a 2d Sprite based Crouch using State machines and animation and all the fun stuff so Lucian welcome to the Stream day is okay it's pretty late there for you I think isn't it um things are going really well with um our platformer we're making a lot of progress uh I can show you I'll show you a quick update before we get into Weston's kind of a preview of what we're going to be doing with our state machine stuff so we have our character which we had before but now uh she can jump she can land she can wall grab she can jump off her wall grabs we can walk through trees and we can also grab onto trees and we can climb and we can hang out in the tree branches if we want to so lots and lots of stuff going on as far as progress here and this is kind of what we're going to be working on with our state machines a little bit later today but first let's get into our first question um came from westerns it was in the chat and for some reason when I clicked go live it went um it went bye-bye so basically the way this works uh or the question was uh could we go over break hit results and specifically in this particular case westerns was doing a sphere trace for actors and then wanted to better understand what the what the hit result was all about so I think probably the easiest way to do that is look at that in context so let's take a look at our base attack for this particular game which is funny because I don't see it here oh it's because it's underneath the plug-in here we go ability so if we look at this in context here's a weapon attack so hit result is all about giving you the information if usually a projectile an object hits another object and there's a lot of information that you can get from a hit result and there's a lot of cool stuff you can do with it so let's take a look at what we might do with that um and actually so to put in context this particular ability fires a projectile which is basically think of it as a sphere that's moving through your scene and as it moves through your scene it might hit something right like the side of my head when it does we want to know about that so all this ability does is it basically launches um a projectile so this projectile is what we're going to be tracking so if we open this projectile we can look in here and there's a lot of stuff in here but overall just imagine the projectiles flying through your scene and at some point it hits an object now that is going to be usually something like your begin overlap so let's see if we can find it here's our event hit teleport tick here we go overlap so what happens is projectiles flying through the scene hits a character and when it does uh we're we're doing a bunch of tests and is that are firing detonate in our detonate let's see where's our hit result so this is where we detonate once it once the once the projectile hits then we we're going to detonate and as we go through here we're going to do some deactivation here's our sphere overlap okay so the projectile hits it detonates when it hits and detonates we're going to do a sphere overlap which basically is going to look for actors around us and if that's good we're going to get our out hit so there's lots of different things that will give us an out hit sphere overlap usually like things like line traces overlapping actors basically anytime where you're projecting something out and you're saying did it hit something if it if that's what you're asking yourself did it hit something then what we want to know is information about what it hit so on any of these sphere Trace line Trace all those kinds of things there's an out hit if we take this and we drag off of it let's just break this now there's a lot of different things a lot of different uh information that you can get when uh in just in general you can break pins apart to get all the information in this particular case the information we get is the actual hit result so if we go through this a lot of these are going to be pretty obvious in the sense that it's like um what was the distance where was the location so some of the big ones the easiest ones uh to understand is location where did the hit happen what was the impact point and if you Mouse over this it will tell you where it was so the location the actual contact point of the trace shape with the surface of the hit object equal to location in the case of initial overlap so in general I'll do this normal is great let's say let's say that you are dropping um an arced projectile and it hits an uneven surface and you want to spawn an effect that grows I don't know grows a flower out of the out of the ground well you want your flower to grow upward right that's where you would use the normal so these are what your normals are for this is the hit actor what is the actor that it hits so let's just say you initially want to know is did you hit an enemy so you could just do this you could say from the hit actor you could say does the enemy have the tag and in this case I would check for 2D enemy because all my enemies have a tag called 2D enemy for example um so that might be another thing a hit component did it hit this did it hit the Collision capsule did it hit some other part of the body Etc now if you're hit or your characters are set up or the actor is set up to have bones physics and stuff like that you can actually get where on the character it hit which bone was hit and that's where you get into stuff like this your hip bone names and things like this a lot of these are going to be uh your uh faces if it's geometry and so on Trace start and Trace end I'm pretty sure I would have to draw these to see what this is actually doing I feel like I feel like it is just going to give you the trace start and end as part of the hit result so that because sometimes what you do with your hit result is you'll take this let's see if we do it here yes okay so here's a great example why is if we break this up again just so we do this break the hit result if we break this why do we have the trace start and end here this is basically a duplicate of the trace start and end of our initial line Trace that we were checking the reason it's part of the hit result is because look at what we do with this hit we take this hit we package it up into a hit result and we send that to a gameplay effect that does damage so we're gonna take that whole hit package and we're gonna send it to something Panda what is going on Welcome to the chat so we're going to take that whole hit package and send it off to something else to process well while we're there we may not be able to get back to the initial information that we we started this whole thing so we may need to let's say that we wanted to do a a quick Trail or a vapor trail or something we needed to know where the initials start and end came from that's why we packaged that up and hit as well so that's kind of a quick breakdown of the hit result there's a lot of different things that happen uh or that are in there and useful depending on the situation and you'll just you'll find a lot of times it's just as simple as if you drop this open I just need to know the hit actor now in this particular case this one's kind of fun I believe do GE damage level I believe this ah okay this is actually not connected it was before so this particular thing was repurposed what happened was when you dropped a grenade the Damage Done here's a great example of how to use a hit result when you drop the grenade the grenade blew up the Damage Done was not the same for everyone the Damage Done was based on the distance you are from the center of the grenade and so that's what initially this hit result was being used for um to basically take that distance and use it as a multiple for the Damage Done so if you're you know if you're further away you don't get as much damage so Panna we are uh Weston had a question about the hit result just kind of explaining a little bit more about what that is and but today's topic is going to be State machines if you all don't have any questions so we're going to be doing a lot of stuff with our animation State machine creating a new uh we're gonna try to create a Crouch we're gonna do a bunch of stuff today so let me double check our chats and see how we're doing there and then we'll also check I didn't see any questions in Discord so I think we're good to go okay great cool so with that remember e sort of as in nmbp so uh first let me just check do is anybody have any questions before I hop into State machine stuff crickets okay so let's let's talk about State machines so there are generally speaking when we talk about a state machine most people are talking about the animation blueprint but there are other uses for State machines as well to a certain extent your behavior tree for your enemies is kind of like a state machine but in this particular case what we've done is we've taken the state machine class and reused it to create a new kind of state machine that can be used for any kind of things there is a there's actually a plug-in that does this called digital logic pro uh it's actually I think it's actually currently on discount in the marketplace and I love it I mean the thing is awesome so let's just go into how it works but it basically just works like a normal animation State machine so first let's start with the problem all right and an introduction to what's happening so we have our character and she can move and she can jump and when she jumps she goes through different states there's the take off there's the law there's the the jump and then there's the in air and then there's the landing right those are all different states another state is when she hits a wall and she grabs onto the wall and now she's on the wall jumping and grabbing and things like that okay well so let's take a look at a couple problems with our states if I run off this ledge notice how she didn't switch to falling that means we have to fix our state machine to change it so that it knows that if we run off a ledge she should be falling what I mean by Falling if I jump way up here see hit this pose that she's in and she's falling if we go like this you can kind of see this pose okay that's the pose we want to go into when she runs off a ledge so how do we do that intro to State machines so that's non-state machine that is our our flipbook all right so the way a state Machine Works is and if you're familiar with animation State machines it's the exact same thing you have an entry point then you have a state and usually you name your state something that's meaningful and inside the state you do stuff so for example this is misnamed in fact let's rename this this is currently idle okay so when we start this state machine the first thing that happens is it goes to idle okay inside idle what happens well if we go in here and we look what it does is when this state starts it sets the flip book for our character to be idle sets it to looping and then tells it to play from start okay now once we're in this state and in fact if we press play I'll press play and then leave that in the background we can actually look at our state machine here let me pop this out we'll do this like this so you can see this is actually going to be a little hard okay so you can kind of see the character is not moving and currently the highlighted state is Idle it's been active for 14 seconds now there are you can also see the potential path that we could take well this is the transition all right and the transition is controlled by a transition rule okay and in this particular case the transition rule will let us transition from idle to jump windup well what is the rule that lets that happen well in this particular case if we look at the rule what we get is is does the character have the jump tag in other words when the right now the way this character set up is when we press jump it adds a tag to the character for jumping and when we finish jumping we take off the tag so here's what's going to happen when we come back to our state machine this is going to be fast you'll see it go from idle zoom out a little bit this is going to do a lot because there's a lot in here so what's going to happen is it's going to go from idle to jump wind up inside jump wind up what's going to happen is it's going to play our uh jump then what's going to happen is it's going to look at all these other potential paths that it could take and depending on which ones of these are true or false it might go to the next thing so in this particular case we have our wind up and then this transition is controlled by time so basically if we are in windup for three frames we're going to transition to the actual jump and then the jump if we're in the jump for longer than 12 frames because I was looking at how many frames of Animation I have in my flipbook then it's going to transition to the falling Loop now let's watch all this happen and it's going to be fast so if we press play you'll see we're in idle if I jump you'll see it goes and comes all the way back to idle now that was fast all right let's slow this down so we can see it so first um I wish how do I do this oh I have an idea let me see if I can make this this smaller yeah we can do this so I can make this bigger so you all can see it better oh we're going to come back to that later okay so let's make this a little bit bigger and then what we're going to do is we're going to slow down let's get rid of details for right now this bigger bigger sound what does that look like is that does that cover the screen law no we don't need that that doesn't no there we go okay that looks pretty good Okay cool so is it smart we have a question State machine is it smart to add a tag to the player like that isn't it gonna like that isn't gonna gonna affect hold on let me read that again let me read that question is it smart to add a tag to the player like that isn't it gonna affect okay um I don't there's two parts to the question the first part I understand ah a performance okay cool isn't gonna affect performance no uh well I'm not going to say no but adding gameplay tags is actually one of the best ways to handle performance here's why there's a lot of reasons why okay first off a gameplay tag the gameplay tag system basically replaced the old actor system or the actor tag system the tag system's still in there but it's you know generally using that it's it's not that it's dangerous but it's Error prone gameplay tags they're set you you pick them from a list it's a curated list you don't have to worry about mistyping or anything like that simply adding a tag to an actor is not a big deal okay now what happens is when you add a tag that that just basically sits there as a little bit of text that can be read now fast forward you're doing something and you want to know if your character is jumping well typically a lot of times what people would do is they would cast to their character they would get um get the movement component and then find out whether or not the velocity is vertical or if they're in the following state or whatever I don't have to do any of that I don't have to cast I don't have to do anything I can just get a hand on the actor and see if it has a tag it has a tag I know it's jumping so it's actually potentially uh even better because it goes along the Paradigm of decoupling our assets we don't have hard direct links so we're trying to keep things modular so basically I can reuse this Logic for any character it doesn't matter how they jump whether they have a movement component or it's custom done or whatever by adding that tag I can have them call it's almost like using blueprint interfaces in the sense that it's all about decoupling right keeping it efficient in that in that way so getting back to this what we're going to do hopefully that answers that question what we're going to do is uh we're going to jump and you can see it go around the lot go around the loop but let's slow this down so I'm going to turn on debug and I'm going to set this to slow-mo 0.25 all right this time when I jump you'll notice it goes to jump up then to jump then the falling Loop then back to land and then finally back to idle okay it's a little bit easier to follow if we set our slow-mo to 0.25 um okay so that's how the state machine works it basically has States you're doing something in the state and there's a transition that controls where you go so now let's take a look at what we were originally now that we know what a state machine is and how it works let's take a look at what happens when I'm running here right now I'm idle okay and when I go to idle and I fall off you'll notice that it doesn't transition to Falling Loop let's take a look at that that is because I'm gonna redock this stuff now that now that you all have your heads wrapped around this let's go like this okay and the code over here okay cool so that's because when we look at this there is no way to go from idle to Falling Loop so we need to add a transition that's all it's it's that easy we just need to add a transition so that idle knows how to get to following Loop okay so here's what we're going to do we're going to just drag off one of our transitions and then we are going to add a check okay and the check that we're going to add is I want to see what are we doing here I'm going to just add this check to see if the character's falling okay so in our transition right now it doesn't evaluate so I'm going to add checking the movement component to see if the character is falling okay so if the character is falling we're going to transition to uh not there we're going to transition to falling Loop so let's go so here we are this is technically idle but we're going to change this in a second to make more sense we're going to go from this we're going to run off and we should transition to following did you see that transition and it's because we added in that that transition now let's let's do a couple more things with our state machine thank you okay are we back foreign okay cool all right so uh I believe depending on where we were where we left off was we had just finished adding the running state but as you can see she never stops running so what we need to do is we need to add in another state for idle okay so let's do that let's go back to our Anna manager State machine and we're going to add in a new state I'm going to call this idle all right and what we're going to do inside of idle is similar we're going to reuse all this logic and what we're going to do is we're going to just use the idle flipbook instead okay now what we need to do is we need to decide how we get to this state well first I think we generally want to start in idle so let's reconnect this and then what we need to do is we need to go from idle to run for sure so let's add a transition to run and the transition is going to be let's get our movement component and let's check our velocity uh wait do I want movement or do I just want the character velocity get the velocity I think either one works here we go we'll get our velocity and let's just check to see if our velocity is greater than 2 for example but first I need to get the magnitude of this Vector length greater than let's say two connect this all up press Q format it now we can get really fancy with this we can have the transitions uh lurp in and out and all this stuff but basically the overall just now here is we start we have our idle then we have our transition and we should go to run now here's the trick let's just test that real quick so when we start we should be standing still I think what's happening is my unreal is using 4K textures for all those trees and so it's just dogging the machine so I may restart unreal here in a second so as you can see the character is idle right and if I go to move she starts running but she never stops running okay so what we need to do is we need to provide a way to get back to idle so what we're going to do is we're going to connect our transition back the other way we're going to do the exact same thing as we did when we decided to run if we don't want to run and we want to go to idle we want to check to see if our Vector length is less than or equal to two and if it is then we'll go back to idle so let's um and I may just restart it here in a second but just to show this out let's just go ahead and press play here okay so we're in idle we walk we stop and she stops so we're basically going from idle to run and then back to idle again cool so we basically we're able to using the state machine go from idle run and back now here's uh another issue okay and the issue is going to be if I play this again let me just I'm almost done with this so I hesitate restarting right now because I'm almost done it so let me let me try this um I'm just going to show you our next issue you can see when we're running and we jump she does her jump and she plays her animation but if we idle and we press jump oh interesting she does I was not expecting that oh hold on let's see what's happening here here's my guess my guess is the minute what happens is the reason this is working is when we're idling what happens is we go from idle to run to jump so she's passing through okay this is a good thing to chat about what's happening is when we go when we jump we are changing our velocity so what happens is we pop in to run real quick and then from there we go straight to jump wind up so we're kind of going through the Run animation to get to jump we don't really want to do that so because maybe there's some there's some frames in there that we're adding that we don't want so all we need to do is add another transition to jump okay and when we do our jump wind up and we're going to copy this exact same thing to see if they have the tag and if they do we're going to go ahead and make that transition to jump and this will clean it up and then what we want to do is we want to change the priority I want jump to take priority over run in this case so to go to run I'm just going to change the all right priority but I lost my details panel I'm trying to remember how to get it back I need to window details here we go so what I want to do is I want to change the priority of this so the priority on this one is going to be one because with this particular State machine if you Mouse over this lower number transitions will be evaluated first so it's going to evaluate the jump in this case before the Run so it should go straight if we pop this out we'll do one more quick look before we get into making a Crouch here okay and making a crotch is going to be cool because we're going to be using stat tags we're going to be doing some animation authoring and all kinds of stuff like that so here we go we're in our idle we want to see is when we jump now that it doesn't go through run to get there see how it went straight to jump so it's not going to run to get there okay which is cool now there is a thing where when we land it it's going through it's basically going through run to get back to idle so you could argue that we also need to fix that so we basically come into landing and then what happens is when we land after 0.27 seconds what it does is it goes back to run but what we could do is we could add an and in there if it's been nine frames because that's how long nine frames is basically our Landing absorption or our impact so after nine frames it goes to run but what we could do is we could say after nine frames and if the movement velocity is still greater than two we go to run but if it's not go to idle so we could easily do that by going in here grabbing our our not our Sprite our character getting our velocity and then with this velocity getting the magnitude again two sure getting the vector length same deal and then if that is greater than two and then we'll add in an and here so if you're not familiar with logic operations you can just say it out loud and it will make sense for you okay if we have finished our Landing animation and we are still moving then we're going to transition to wherever this goes to in this particular case it goes to run now what I want to do is I want to copy this transition and I'm going to put one into idle and what we're going to do is we're going to change this to be less than or equal to 2. and if that's true it will go straight to item so basically we've cleaned this up so that our character can now go from idle to run run to idle idle to jump and Landing back to idle or to run so that cleans that all up so that is a quick kind of like brief overview intro to a state machine that's how we're using it right here to handle our 2D animation blueprints I'm so much happier using this because trying to manage all this logic in the character blueprint and stuff like that and all of these Transitions and rules I just I think personally I naturally think better in state machines so let's just save all this this is cool now let's double check our twitch stream we're good over on Twitch no questions here we go before we move on to our our next phase does anybody have any questions they want to throw out [Music] I'm Gonna Save all these and I'm also going to restart unreal all right so our next phase we're going to create a Crouch so let's do a couple things because I also want to take some time to show you some of the pain that I have found with animating so let's go to this here and what we're going to do is we're going to do a very quick three frame animation to create a Crouch and I'll show you what I've been doing and this is so much more than I'm supposed to be doing right now um because remember this character is being modeled in 3D and so a lot of these things are going to be potentially redone based on the style in 3D so I'm just I'm just having a lot of fun with with the Sprites and everything right now and it's great being able to prove out logic and all this kind of stuff so black Panda I don't think I understand interesting this and the Char and MBP ah okay um from a state machine standpoint there there isn't a whole lot of difference um in fact I'm I'm pretty sure it uses the exact same state machine logic and code MC plus but the difference between what I'm doing here and um between what I'm doing here and an animation BP is an animation BP is special in the sense that it also has all of the hoses and transitions those are specifically set up to be used with 3D characters okay there are no bones in this character to use it's just pictures so I can't actually use the animation blueprints in order to drive the animation for this 2D character so what I've done is I've taken out just the state machine and I'm using just the state machine part of an animation blueprint or you could say you could say an animation blueprint uses a state machine and I'm just using a plain State machine but what I what I'm not using is I'm not using all the logic for being able to blend poses and things like that like there's no way to blend a 2d Sprite so there's no later blend per bone there's none of those things so State machine wise it is the same and that's why I wanted to use it because I wanted to use that same logic to drive this stuff um okay so let's take a look at our idle clip so this is this is Adobe animate it's a it's a it's a tool it's fun to use and this is our idle all right just like you do with um and and keep in mind I'm kind of making this up as I go so but based on a lot of experience with animation and stuff too but the same way that when you're working with 3D characters you have an idle pose you generally want your animations to start from the idle pose so that as they transition the transitions are smoother and stuff like that there's lots of exceptions lots of different ways to handle that depends on your style what you're doing Etc same thing for the paper 2D Sprite stuff okay so I'm generally starting all of my animations from my idol so what I'm going to do here is I'm just going to take all of these frames I'm just going to take the first frame up my idol and I'm going to start this as the starting point for our Crouch and I thought it would be fun so let's save this as Crouch this is going to be Crouch and let's just do a very quick animation using Adobe animate to do this all right and the way this tool works it's kind of wild I'm just going to go three frames in we'll set some keyframes and we're going to start with the body and oops undo I don't need that and we're just gonna scrunch it down so you put these little bones inside your character 2D image and you can kind of squash and move it around like this it's cool just gonna have it slightly lean forward and then her head's going to come down okay so over the course of three friends she's just gonna go like this okay uh we could we could do some stuff with our legs and everything like that but I'm not gonna worry about that and then let's move our tail down and then we can also pose our tail a little bit just to get something that makes sense all right so that's our crotch super simple right okay now let's talk about the paint and it just transitions out so this is three frames we're happy with this right okay it looks good so let's just pretend this is our crotch now this is where the fun begins if I wanted to uh and let's rename this this is gonna be our Crouch clip so it's not the idle clip anymore um Adobe animate has the ability to export these frames or I can make a sheet so if I right click on this Crouch I can generate a Sprite sheet and when I do that it will create this image and I can make this I can make this bigger you can't make this window bigger unfortunately but I think I can swing it down so you can see here here's our Sprite sheet which is cool and then you can preview what it looks like too right it's just a crotch nothing crazy all right so let's just export this and we're going to export this to where's this going to oh this is going to export as a sheet okay so let's see where this is going um we're going to put this into desire sheets and this is going to be a Crouch uh sure let's save that okay and Export that okay now this is where we get into the fun uh I need to figure out a proper system of registering registering an animation is where it comes from the old 2D days where when you did a drawing you had to make sure it lined up perfectly with the drawing before that and so there were two two long holes and a single Center hole that you would use to line the paper up so that it would all line up and all your animations would line up properly well I don't I have not found the proper way to do that yes yet yet with uh the combination of workflows here so we're just going to where I've been doing this manually uh which is something well something that we need to figure out so let's just but we can make it we can make it good enough for the purpose of our Crouch demo so let's see here um run okay I don't want that I don't want to say that either I'm not going to say that so let's take an example this is the idle sheet that I made and basically I made this using a bunch of you know guides and grids so that every image is the same size and so on let me show you the problem if I save this out as the Crouch sheet for Photoshop Crouch we're in the sheets folder okay we can just hide this for now let's open the one we exported from anime which is this PNG file let's grab this and let's paste it in here the sizes don't match see the difference okay so this is where I've been doing fun nightmare stuff which you can't do so what I did was I took and I created a pattern from the initial idle pose that I use as my registration and that pattern is here okay so this is the exact same pose repeated over and over and over again registered to the red line which is the ground plane there's a little bit of a buffer between the bottom I need every single Sprite to line up to this line in the middle Etc so in order to get this to fit properly and match properly what I've done so far is I'm doing a little bit of a manual process and I'm just going to resize this so that I can make this fit and that all my Sprites are the same size so my character is not growing and shrinking as it's animated so I'm using this first frame to register my Crouch if you will and get it to be the right size so here we go and there's a better way to do this if you know a better way to do this already please share that would be really nice um but in the meantime I'm getting this to be good enough because once again if we do end up doing this character as 3D and render out 2D Sprites from the 3D animations now we're operating in a world that I completely understand and we'll be fine okay I think that that is a pretty good registration okay so I've registered the first frame I know it matches now what we're going to do is I'm going to move these over to be lined up where they need to be so I'm going to do that using the feet and I keep this image up in the background as a means to register so there's not Jitter left and right either so probably for this case it's a good example that I didn't actually uh animate defeat because that would have made this more difficult so let's move this over Okay cool so now we have our Crouch sheet so this is our Crouch ready to go so now all we need to do is export this and bring this into unreal we're getting there Let's uh save this and what we're going to do is we're going to I.T Angel how's it going we're making crouches okay we're going to uh save this out because we're using the slicing it's going to save out each image as a PNG so I'm going to save this into a folder called to batch now there's a reason for this I'll explain it here in a second um let me bring up folder View in our folder View to batch we're going to delete all of these okay just so we it's clean so you all can see what's happening all right so we're gonna put this out as two batch Crouch save that cool all right so that put out the Crouch now the Crouch is sitting in this images folder and you can see it put out an image for each frame of our Crouch sheet but we're only using the first three frames so I'm just going to go back in here and I'm going to delete all these extra frames now here's here's the thing when you look at this this image is 680 by 680. all right the Sprites that we're using currently in gain are actually 256 by 256. um so what what we did is I created an automate script this automate script is basically an Adobe Photoshop action okay all it does is resize all of my Sprites to 256 and gives them a name and in this case I'm going with crotch Crouch and want an underbar so it's showing me that each of these is going to be called zero Crouch zero one dot uh GIF but these should not be gifts these should be pngs so let's just hopefully what oh because I didn't move them I need to move them into the folder mistakes so we need to move these up one folder so now we're in the batch folder proper so now we can automate this so let's automate this again is there a Crouch and this is going to the export folder which is great all right so that resized it now let's go back to unreal and let's bring in our couches by it Angel we're doing all right I am uh I'm actually pretty happy about it's like some of the progress we're making overall uh with some of this stuff we are definitely having a a little bit of a glitch thing I need to fix these 4K textures on all these trees but we're still getting through it so let's go back to our textures yeah it is just chugging all right and we're going to make a new folder for crotch um I don't mind doing the aligning work so but but there there is definitely a way and also in addition to the alignment stuff I need a frame safe way to actually create the animations because when I'm over here in Adobe animate which I already closed down and I for example when I was doing the jump if I have the character bend over too far her head goes out of frame so what happens is let me share you with you the mistake I made so hopefully you guys don't make this mistake you all don't make this mistake okay um I set my frame to be a square frame uh 1024 by 1024 for example because I always work way high res than than I want to because I have these I don't know dreams of being high res anyways so I had a square frame and so I animated my character to be in that square frame and what would happen is when she be on the stage in Adobe animate I just animated her jumping and as she jumped as she went through her takeoff she was particularly stretched and as a result of that her head went beyond the squareness of the actual frame so I realized I had made a mistake I needed a buffer on each side for Sprites to be able to account for things like tails and stuff like that so I actually resize I changed the way I worked and I went to from my square frame I could have done two things I could have gone smaller or in this case I went to a from a square frame to a larger square frame that sits in a um that has a cushion and then what I do is I take that and then I'd scale that down and then I added in the registration for the floor and stuff like that so let's import our Crouch now and we're going to do that from our export folder here's our three Crouch frames now I'm going to import the first frame but in practice we're probably not going to use it I'm going to right click on that I'm going to apply the paper settings I am going to right click on that and I'm going to create Sprites but it only created one Sprite what leave this it also looks like proforce is not connected hold on let's get this going because it can cause problems with naming later okay this is stuff I want to learn and I keep missing your stream but that is because I'm busy at work lots of I'm not 100 sure it would work since you need it in a spreadsheet and all on the same size you can try in [Music] ASE prite pixel art software but you probably need to start there not after you did some I don't mind redoing it it's I haven't done that much work but there has got to be I will check out the pixel art software and see I mean I was looking at toon boom I was looking at a bunch of different things toon boom would absolutely be able to handle this I know that but I also um I also already have an adobe membership because it's such an amazing price that I didn't want to spend more money on toon boom and learn a whole bunch of stuff and also there's like an overhead especially considering this may all actually be done in 3D so let's just take these and let's convert these two Sprites um Sprite actions we're going to create Sprites and then from these Sprites we're going to create a flipbook and the flip book is going to be our is there a crotch and we're finally getting to the what do they call that the day new Ma um where we're actually going to implement this Crouch as an animation for our characters so okay cool that's that they're gonna drop that in our animations folder so here's our couch now I don't think we actually want the first frame of this crotch because it will cause a delay I'm gonna keep it for now but I think ultimately we will end up deleting that first frame all right now so we have our animation so we we've successfully animated our Crouch we properly registered it we got it to the right size we've imported it now we need to get it to play on a character it's a couple steps to this okay so to do that there is a free version called Libra spite I think that which is the Ripoff of it but AE Sprite is a professional software for Pixar energy but I'm assuming because you work Fuller so yeah we'll have to take a look at it I think one of the reasons that I I went with the Adobe anime again was one I already had the I already had it and two uh it was super quick for me to add in those quick little rigs to deform the stuff which I thought was a lot of fun which was cool all right so what we need is a couple things we need our character because we need to be able to tell it to go to crouch so 2D let's look at our 2D hero Pawn and what we're going to do is in here when we do jump down we're going to add a tag to our character okay now it's interesting because jump down is actually kind of crouched I think we might be able to just use interesting we kind of want to know if they if they Implement pass-through so let's do this pass through actually no either way I think we want to add the couch let's add one more tag okay and this tag we're going to add we're gonna we're gonna create it anyways just so you can see so we're going to add a crotch tag and we're going to add that to our player state okay and that just puts a tag on on the player saying Crouch okay so now what we should be able to do is back in our uh anim State machine we should be able to check for that tag oh we're gonna go over time we're not gonna get this whole demo done in an hour but we'll be close enough okay so let's just do this let's Let's do let's add a new state and the state we're going to do is we're going to crouch okay and we're going to go from idle to crouch technically we could go from any of these to crotch but for now let's just just to test to show we're gonna have to do some work in the state machine um let's let's grab this and let's take that um oh we're gonna have to do we have to do two things in Crouch but let me let me get to that in a second so first thing we're going to do is let's just set our flipbook to crouch okay we're gonna start we're not going to start looping because we don't want it to Loop and it's going to be interesting to see what happens here and the rate the way that we're going to go through this transition is we are going to check to see if the actor has the tag okay and the tag that we're going to check for is crotch see if this works uh Crouch okay I mean your workflow will be the same just you'll need to use AIDS right instead of Photoshop but now I'm really sure oh I see I'll check that out are you going to post these streams on YouTube so I can check it out later it Angel yeah they're all there they're every single stream we've ever done live is on YouTube if you click on the live section they all of them are there and I'm getting better about having a schedule for the stream so like you know intro answering questions and having a topic like today's topic is State machine um we're discussing whether or not we're going to keep doing the live streams or I'm going to be doing pre-recorded videos and doing more Discord stuff but so far there's at least one vote to keep doing the live streams um all right so we now have our our transition rule to go to crouch but you'll notice it's red all that means is that there's no way to get out of Crouch but that's fine because we just want to test to see if this works so when we play it's doing Crouch it's looping so it is working it totally works okay so let's do one more thing let's do a Crouch Loop so let's add a new state and this is going to be Crouch Loop okay and what we're going to do for this is we are going to cheat a little bit and in our animations for Crouch we're going to take this last Sprite and we're going to create a flipbook for it called Crouch uh Zera Crouch Loop and I'm going to move this into the atom folder so now we have where's our Crouch Loop here's our crotch Loop okay so all we need to do is in our state machine after two frames we want to go to crouch Loop all right two frames is roughly stride .06 and what should happen now is we should go if we compile this we should go from idle to play our crouching animation to the loop now in the loop it's just going to sit there um and what we could do is we could let's compile this and let's play I'll show you what there's two things this state machine is going to get a little more complicated but you'll see so if we go down uh that was not quite what I was expecting what is happening where are we it's in Craftsman oh we didn't change our animation we totally forgot to actually do the do the work inside There's Hope here we go okay and this is going to be Clash Loop compile and save let's try that again this time without the oops so she stays there perfect okay now let's go again this time though what we're going to do is we're just going to drop down because I don't wanna I don't want to trigger yet I wanna I wanna see if it works when I'm just standing on the ground and it doesn't require me to drop down so if I press down again she crouches okay now what she doesn't do is uncrouch so we're going to have to do a little bit of work here so that she uncrouches and there's the crouched state for her is like she just everything she does now she's going to do crouched because there is no way in this state machine to get out of Crouch so what we could do is we could say um we could say after some time uh we could say after key is pressed or we could do the transition where uh velocity changes so if the velocity changes to [Music] let's try that let's this is kind of wild we'll just do real quick to wrap this up I think this should be velocity change yep so if we're here and we Crouch and I start moving she unconscious Crouch unconscious Crouch now there's a little bit of a delay you can kind of feel it it's really hard but if I'm running ah I'm not removing the tag we do need to remove the tag um so if she's going to crouch all the time right now because I have to remove the tag so what we need to do is in Crouch what we could do is here let's go back to our state machine once we Crouch in our Crouch Loop let's get our uh paper character get the player state this always happens just one little more thing we can make it so much better if we just keep going even though we're supposed to be done okay so we get to player State and let's remove um a stat tag an account I I am currently removing 100 of them every time just because but you don't have to do that okay so let's do this cool so that would remove the stat tag so once we hit that Crouch we should no longer be crouched once we start moving so she goes back so that gives us the full loop so we have successfully fixed a bunch of things with our animations so that our character can do all kinds of cool stuff now I also completely changed jumped so I have to fix that but watch this it's fun she can jump forever I can jump she has infinite jump so she can jump all around the level anytime she wants to so obviously we'll have to fix that but I think we are in a good place to wrap up for today so let's go ahead and do that how was that everybody tried a little bit of a different format today having actual specific topic to talk about uh and go through a quick little demo like that um did anybody have any questions before illusion here we go I had a quick question before we wrap up it says um did you make your state machine entirely in blueprints the state machine is a so there's two answers to this I the state machine itself is a class that you can create um I did not if you wanted to you could um you can basically just instantiate the state machine class and and um C plus plus and then from there create your own State machine I did not want to spend time doing that and that's something I said at the beginning is I think it's called digital logic pro it's a whole like plug-in that you can get for unreal um and it has that code already done for you and it's currently on sale so I went ahead and bought it I'm not I'm not like uh I'm not saying you should or you should not you know this is not Financial advice for all of you follow do your own research type thing I will say this the amount of time it would have taken me to implement my own class build all this stuff to start to get to prove out the Prototype and everything for me personally it was worth 120 bucks it's on sale right now for 120 it's usually 250 or whatever there's a free version too but could I have done that had total control yes but absolutely worth the multiple hours it would have taken me to write that code myself slam dunk easy win in my opinion for myself you all can decide I am actually very excited I'm not gonna lie I'm very excited about using that for not just this am State machine but also um I'm going to do some attempts to change my character Behavior trees to use State machines instead which is I think um it's just the way my brain works is better with State machines as well so so and again it Angel you can go back and uh check out the live stream they they're almost they're posted almost immediately once I finish and then usually I'll go back and I'll update and put in markers so you can find the stuff I need to go back um keep an eye out I'm going to be working on there should be some new videos coming out on blueprint interfaces some of self-contained stuff if you all like this format and you want me to keep doing it help me out spread the word we don't get a lot of questions right now and so it may be the kind of thing that we if we don't if we continue not get a lot of questions I may move to a more pre-recorded format and just do the live stuff in Discord if you guys like this format let me know help spread the word as always throw your questions in Discord uh send me an email with them whatever it is and then also let me know what other kinds of things you all want to learn about uh if this was fun if you like the way this is going that's great too again my name is Kevin I you know we're here twice a week I'll be posting next week's schedule later this week keep an eye out for it should be Sunday and Wednesday 11 30 a.m Pacific Standard time and I hope everybody has an amazing rest of your weekend or week and then weekend hopefully I will see you all Sunday don't and I'll probably be I'll probably be working in Discord a couple nights later this week too for anybody who wants to hop in and hang out all right take it easy have a good one foreign
Info
Channel: Ask A Dev
Views: 518
Rating: undefined out of 5
Keywords:
Id: lqz0QuMJEAY
Channel Id: undefined
Length: 67min 8sec (4028 seconds)
Published: Fri Sep 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.