Blueprint-Only Input Buffer System (Part 10) | How To Make YOUR OWN Game | UE4/UE5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign what's up guys from the Bro here and we are back for another episode of The Blueprint only input buffer tutorial Series so this is part 10 of the series and specifically in today's episode we are going to be going over changing our input buffer to be a circular array or a circular input buffer a circular array is an array that has a certain number of elements in it such as 60 for 60 frames in a second and every 60 elements it starts back at zero so instead of infinitely increasing the number of elements in the array or removing them after a certain period of time from the array we can reuse the same allocated memory and just keep replacing the information as far as functionality goes you're basically just going to be able to do everything you've already been able to do however in a much better way this will allow us to truly go through the input buffer how we expect to and how fighting games do so quick demonstration if I press my two inputs to do my first command I perform that command if I perform the inputs for the second command I'll perform that command don't worry about the actual animation just look at the top left where the print strings are occurring and also show you the output log so here's command 1. command two command four is by pressing this button releasing this button after a given number of frames is command three lastly is command 5. and command 4 has the same input as one of the inputs in command five so they both triggered so essentially after this episode you will be able to perform press inputs release inputs charge inputs and multi-button commands all using this system that we already have except converted to a circular array now for those of you that want to get caught up in the series I'll link this playlist right here in the top right corner you can check out all the blueprint only episodes and you can see how we got to this point in the miniseries additionally if you care about the other things you see in this episode such as the movement of the character the health bars on the enemies the actual equipment on the ground and being able to pick it up and utilize it you want to check out this place right here which is the playlist for the third person and action RPG tutorial series otherwise let's go ahead and get started so as usual this is the blueprint only input buffer tutorial Series so even though it is modeled after our fighting game one it's blueprint only so we only need the blueprints today we don't have to go into the code of course so let's go to our Blueprints and I'm going to go to my base character BP we're going to do all of our logic in here today now I'm going to give you a quick reminder of what's in my command list First Command is my two special inputs both a press so just pressing these two inputs within the given number of frames which is going to be 15 after this episode is complete Command 2 is going to be forward left and jump so pressing directional inputs as well as an actual input action command 3 is just releasing the attack button after 100 frames of charge so basically holding it for 100 frames command 4 is just pressing the attack button so it's a single button but it has the ability to be held for 300 frames before it automatically executes the remainder of the command which is the release section and lastly command 5 is a multi-button or multi-input command where we have to press two buttons at the same time and releasing one will void the attack so pressing attack and my one special move at the same time within two frames of each other will trigger the multi-input command everything else in here is the same as you have been used to nothing else has changed so we can go on with the actual logic in the graph so getting started in this event graph here let's go to our event BP tick now again I am doing this blueprint only input buffer tutorial series within my third person in action RPG tutorial series but they are completely separate you could use this with any project that you want so I am creating this BP tick because I have a code tick for my third person Series so I made a BP tick and this is where I had done all of my tick logic to this point the main benefit of this system is being able to press multiple inputs on a given frame and check against those values so if we want to access any frame at any point we can check all the inputs that were pressed the states that were held and really whatever we need to about our input having this array that is constantly there the size doesn't change so we can always access the correct element based on the tick that we're on so in our blueprint tick we were just basically keeping kurtick which is current tick add a value between 0 and 59. 0 to 59 is 60 different values and so that is assuming we were playing at 60 frames per second those are all of our possibilities for one second we were actually already doing this from before this episode but it's going to come into play a lot today now this next part I've added everything else after this function is something that has already existed in the series and is shown in other episodes in the blueprint only input buffer tutorial series this is all for our charge information and our multi-input commands this however what I've added right here is new it has not been in the series and that is what we want to add today this is the only thing we have to add to tick is what's highlighted right here so now we need to start keeping track of whether or not we've captured input every frame because it's not just about when we've pressed inputs and when those inputs should be destroyed anymore it's just keeping track of the entire frame history so however long we decide to go which I'm gonna go 60 frames store 60 frames of data that way we can access those frames at any point in the data within them the data that was pressed on them are released on them or whatever it may be our goal here is to be able to track 60 frames of data I'm choosing 60 again because there's 60 frames in a second assuming we're running at 60fps and so that is a good amount of frames it'll do everything we need but also it's not too much you don't want to make too many and then you're tracking too much data because of this it's very possible that the majority of those frames aren't going to have input pressed on them but we still want to keep track of that and say nope no input was captured this Frame because if input was captured on a given frame we want to set the array element of the input buffer at that current tick value or at that frame value so if we're on frame 30 and we pressed attack then on frame 30 we want to store the input State attack if we haven't captured a frame on that input then we still want to have an F input info structure for that frame for that value in the input buffer except it's just going to be a default value so let me show you what this looks like if we come into the game and I go into my base character BP and we go into the input buffer now the input buffer already has 60 array elements everything zero right now because I haven't pressed anything so if you open up any of these they're just the default F input info structure which is what input buffer the variable is a type of input buffer is an array of f input infos if I just start mashing buttons in here you'll see that at some point I will happen to hit an input on index 0 of the input buffer right there and so it has the timestamp it has the status of what happened and then eventually it gets cleared out and reset but notice how for a second or so this information was stored up to 60 frames later than that this information was valid before it was removed when we press one on a given frame of a second so this is the zero index of that second so really this is the zero frame but it's the first frame that we're capturing for that second as I managed to press a button at that point this information gets filled out then if we come around again one second later and I haven't pressed any input on this Frame of that second this is going to be erased and just filled out with none going back into our base character BP now this is what we need to do we need to make sure that if we haven't captured input on this Frame that we make a default input info structure that we can use to pass to the input buffer at that tick or at that frame for the second otherwise if we have captured input for the frame then we just want to say we haven't captured it for the next frame this Frame is already done at this point because we're on tick so for the next frame we want to reset this value back to false saying nope we haven't captured input just yet for those of you that have watched the fighting game tutorial series you may know that the captured input this Frame is also used for when multiple inputs are pressed on the same frame and that will be our final topic of the blueprint only input buffer tutorial series we will then have an episode on enhanced input so that we can get everything working that we have in this series in the enhanced input system to get started on this logic right here we want to make a new variable called captured input this Frame and that's what we're going to use for this section so we can just make a new variable by pressing the plus here like we always do and I'm calling it captured input this Frame Boolean as the type and right now even though we haven't set it we can go ahead and set up the ticklogic because fundamentally we understand what's going on so it doesn't matter if the value is actually there right now or not we will set it up to be that way in just a few minutes so we can get our new Boolean and we can check not bull so basically we want this to be false if we haven't captured and put this Frame that's when we're going to make the default structure so if we bring this into a branch the branch is true is really saying that we haven't captured and put this Frame so that's what we're trying to do now we are trying to create the default input to pass to every frame where a player did not press the input in my case it's going to be make F input info because F input info is the name of my structure the node is going to come out with all the default values filled out that's all we need we don't have to set anything we want the default values because this is an empty structure the player hasn't pressed anything on this Frame that's what I have here now our input buffer we can get that and we can drag off of it and type set array element which is for set array element you need to pass it an index in the item you're adding at that index for the index we can use our ker tick which is our current frame for that second because at that frame of that second we want to place this object for the item you pass in the make F input info return value you don't have to say size to fit here this will change the size of the array to make sure this element can be added if our logic is set up correctly and we are actually using a circular array for the size of the array won't ever change it's not required to check that and it's a little bit faster if we have it disabled so I'd recommend leaving it off now for the other case the case saying that we have captured input this Frame so if not captured this Frame returns false that means we have captured and put this Frame that means we just want to reset our captured input this Frame Boolean back to false that way we can go start our next frame for that second with a clean slate we're saying we no longer have captured input for the frame for resetting our value that way we can start back at the same state we started our last frame kind of a mouthful so essentially what we need to do here is just reset our value back to its default which is false so you can just set captured input this Frame to false regardless of what the branch takes if it's the true or the false they're going to meet up and they're going to lead to the rest of the logic that we had in the blueprint tick this is all we need for the blueprint tick function or the event so we're good with that now our input buffer will be filled out every frame with that correct data or it would be if our input buffer had any data in it by default our input buffer actually did not have any data what I've done now is added 60 blank elements because again we're not trying to resize this array anymore so by default by clicking on the input buffer going to the details panel default value you can press the plus here to add elements to the array I would add 60 elements that is zero to 59. they're all empty right now but don't worry when we go into our ad input to input buffer function then we're going to fill these out at the frame that a player pressed an input with the input data that they actually entered so the next thing we have to do is go down to our perform input logic function perform input logic is called from any of the input actions based on if it's a pressed or released with the key that was pressed to get us there we set this up in an earlier episode so I'm not going to go over it but in this perform input logic we were checking to see if it was pressed or released and then we were removing any old inputs from the buffer remember remove old inputs from buffer went through determine how many frames apart these inputs could be added them to an array to remove them and once we were done iterating through the array we removed the values that we had to but again we're not doing that anymore so you have a few options here you could leave pressed and release plugged into where they were and disconnect the node here so that remove old inputs from buffer just didn't do anything Additionally you could do what I was doing there in the demo which was to just bypass these nodes just skip the remove old inputs from buffer function calls or you could go as far as to just remove these function calls from here and so now my perform input logic just looks like this so it's actually even simpler than it was before we're not adding anything here we just don't need to call that remove old inputs from buffer function anymore because we're not removing them we're just going to overwrite them every frame so if nothing was pressed then we don't utilize it if something was pressed then we're checking against it to see if we can perform a command you could go as far as to remove this function entirely but I'm not going to do that I'm going to keep it I like to keep my old logic as far as these tutorials go that way I can always reference them and assist people so I'm keeping mine but if you would like to get rid of yours you can or keep it in case you want to do anything with it in the future it really is up to you anyway once we're done with this now our basic event graph is complete we don't have to make any other changes in here add input to input buffer now we call this function within the perform input logic event here we pass the data along that we want to be added to the input buffer let's go into that function now in here it's a little ugly but we're going to clean it up of course so what we were doing before was just literally calling input buffer add and passing in the F input info structure into this input buffer and we were just adding it wherever it's a little bit different now because before we do that we want to make sure that we add it to the actual index that we care about since we're doing it again off of a static array size we want to make sure that we're adding the input that was pressed at the correct frame so we're not just calling input buffer add anymore instead we're going to call input buffer set array element and pass in the current tick so you can remove your add node here and I'm going to space this out a little bit the check input buffer for command we're still going to want but I'm just moving it over so we can fit everything in here and now it's going to look like this input buffer set array element like this with Cur tick as the LM and something like that will do again size to fit doesn't have to be checked but one thing we should do is set our captured input this Frame to be true so we updated the ad to be set around but we've also added a new node entirely which is this one here and we're setting captured input this Frame to be true because we have we've captured input at this point input has been pressed and we've recognized it or released whether it's been pressed or released doesn't matter just an input has been found and we want to make sure that we know about it so that we don't override this input with a none input on the tick I still call check input buffer for command at the very end of this function so make sure you still plug that in and we're good to go with ADD input to input buffer now check input buffer for command is the last function that we need to take care of but it is very busy and very ugly so we're going to clean it up as we always do okay I know this is going to look crazy but I'm going to go over every single part of this most of it hasn't changed it's just that I have a few extra nodes that I've placed up and out of the way which happened to make this really ugly right now but we're going to work through it together because this is building on nine other episodes all for this one topic I'm going to go over the whole thing in this episode that way we're all on the same page so when we get into check input buffer for command we're doing exactly what the function says we're looking to see if the inputs the player has pressed matches any of the commands to do this we were going through all of our commands because we want to see if any of them meet the requirements we were then setting correct sequence counter to be zero our default value the problem with that is correct sequence counter shouldn't be zero anymore correct sequence counter was used to determine how many inputs we've gotten correct while checking to see if we perform this command so for example if backward forward light attack was our Command inputs and we performed backward and forward our correct sequence counter would have gone from zero to one and then one to two it still has to get one more correct input before we can perform the command however we are actually going to Loop through our input buffer backward now because we can't just assume because there's elements in front of our input that we're checking that we want to check it the input buffer now always has a size of 60. remember that so we don't want to check all 60 frames every time an input has been pressed most likely you have to enter your inputs within 2 10 something a lot smaller than 60 frames to actually perform the command say we have four frames of leniency before backward forward light attack well we only want to check the last four frames of data not all 60 frames so we're going to check our correct sequence counter backward so basically if we meet the last input in the input buffer say yes we've executed that one we know we are eligible to perform the command If the previous inputs match it otherwise the command just might not be finished by the player yet in which case we want to skip it so for now on our correct sequence counter is not going to be set to zero when we make a mistake but it's actually going to be reset to the number of inputs in the command so in the case of backward forward light attack that example I was using there are three inputs in the command so the correct sequence counter is going to be two and once we reach negative one then we'll know we have performed all the successful inputs in the command it might be a little confusing now but that's okay let's start using it and it should make more sense so the loop body for the command list was going into the set correct sequence counter zero but I'm not doing that anymore instead I'm setting it to the length of the inputs array from the F command info that we got from the command list at the index We're looping through okay so all of this was already here just literally instead of setting correct sequence counter to zero we're now going to take the inputs array off of the broken F command info we have and we're going to get lengths then off that length we're going to subtract one from it because as always length refers to the actual number of elements in an array but the array indices they start at zero so if I have three inputs in my command I actually have zero one and two those are the indices so I have to do length minus one to get the highest index of the input in that command then drag off that and set correct sequence counter to this value if you want to put it in now you can so for me I'm going to get rid of my correct sequence counter being zero and we're going to fit in these three nodes okay now this doesn't look too bad but it's still very ugly with all these lines so let's see what we're doing here that we can either change or get rid of so the next thing we were doing was taking our inputs array the one that we just plugged in to get the length and we were plugging that into a for each Loop and looping through all of the elements in this array we actually don't have to do that anymore the reason we were doing that is because we wanted to Loop through each individual input and we were breaking that to get the type status required charge frames and the is currently held Boolean this is no longer necessary if we do this actually we'll be looping way more times than we need to we're going to use a new method of determining what elements from the command we should be checking against and that is something called our Max frame between inputs we actually set up the max frames between inputs variable in a previous episode and this is how many inputs we want to have between these frames on our Command before we can no longer execute that action 15 frames is how many frames apart I can press my inputs for that command and it's still triggers so for example if I want to press them if I press 1 this Frame and another this Frame that's too far apart I won't trigger the command however if I press one a little bit faster I do trigger the command I press it really fast of course I trigger the command before that was based on if it was removed from the input buffer or not but we don't need to do that anymore we can just check against the actual number of frames back that we can still perform this command so if I can only perform this command two frames apart so if I change the max range between inputs to 2 this window becomes a lot tighter for me to actually execute this command so now I can press it pretty fast and not trigger it now if I press them right next to each other like that I can of course trigger it so this value represents how many frames apart they can be pressed and we can still execute it we only want to check those elements within the input buffer for this command input so instead of using the array element for this break we can actually get the value of this array at the correct sequence counter instead of getting this for each Loop and passing the array element into the F command input we can just pass in the get into this break so quite literally you can drag off the inputs array type get a reference will be good for us here because our multi-input commands can change values on the actual command input right here and so we're going to make sure we have a reference not a copy when possible so get a ref and then pass this into the break that is already here that's what I've done right here and for the index you're getting the index at correct sequence counter the end result is this right here I'm going to straighten the connection to the get and there we go we can remove that other for Loop this is going to increase our performance by quite a lot now we have one other section up here as well that we have to fit in since our input buffer is that constant 60 size now we only want to check the number of frames between inputs because if we go outside of that range we know that we can't perform the command anyway even if the player pressed the correct inputs we are going to use our Max franchise between the inputs and plug that into the last index of a for Loop up here so max frames between inputs goes into this for Loop so this is a standard for Loop and Max frames between inputs is going into the last index what we're doing in this section is making sure that the frame that we're checking Falls within the boundaries of the input buffer this is definitely a paint scenario so let's open up paint let's just use letters here because it'll make sense so say we had inputs a b and c you can think of what they correspond to such as backward forward light attack or you can just think of them as literal keys on the keyboard a b and c keys now say we had a command command number one and it was a c that was how you executed that command you had to press A and C well in this case the input buffer would just check to see if a was at a certain part in the input buffer it wasn't interrupted by any other inputs and then C was pressed before a was removed from the input buffer and then you would perform the command that was super simple nothing complicated about that however like I said the circular input buffer is much better for a lot of the stuff that we're going to be doing and so we want to make sure that we can do that and utilize that correctly but the way we're checking that is going to be a little bit different because we don't want to check all 60 frames every time we want to see if a and C were pressed without an interruption instead what we want to do to make this significantly more efficient is take the index that we're using so this is a for Loop of zero to 15 for my first command because Max brightness between inputs for my first command is 15. to 0 to 15. we want to take the current tick let's say we're on kurd tick 30 which is half a second in right 60 FPS we're at 30. technically that's the 31st element because of index 0 but let's just use 30 as it's an easier number to work with than 29. now we want to subtract the index in the loop that we're at so we're going to start at zero because first index is zero we're going to do 30 minus zero so we have the input buffer the length we know the length of the input buffer is going to be 60. so we want to say 30 minus 0. and that's 30. and we want to plus the length so Len of our input buffer which is going to be I B and that's going to evaluate to 60. so 30 plus 60 is 90. so 90 is the current value that we want to check in our input buffer but that doesn't really make sense does it there's only 60 elements in an array so how could we have 90 well we can't but what we can do is mod use modulus to get our value of 90 to be representative of where it would actually be within our input buffer so some of you may not have seen this before modulus is the percent sign and you can find it by literally typing the percent sign and it'll be mod integer or modulus like this and you will get mod integer either way you're going to take the result of the addition here and mod it by the length of the input buffer so 90 mod 60. now modulus what it does is it's going to divide this number by this number so 90 divided by 60. but it's going to actually return the remainder 90 divided by 60 if we get the actual number it's going to be 1.5 but let's do it on a calculator so you can see it 90. divided by 60. is 1.5 now the remainder of this is 30. there are 30 left over in this case it's easy to figure out the remainder because basically you know that 60 only goes into 90 one time 60 times 2 is 120 which is greater than 90. so it only goes into it one time so you can literally do 90 minus 60 to get 30 that's your remainder that's what modulus returns so in this case modulus is going to tell us we should check frame 30. if our Curt tick is 30 the very first frame we should check in the input buffer is 30. but that's what all this is saying let's use a different example let's use the next element in a for Loop which would be one we just did zero let's do one so let me erase this and I'm actually going to put another piece of text here and let's say Cur tick and we're going to say that that is 30. we can still use 30 as the curved Tech because we're all doing this on the same tick but now let's look at this again all right so we have kurtick which is 30. 30. then we're going to subtract the index we already did zero so we're doing one so 30 minus one that's going to equal 29. all right now 29 plus the length of the input buffer we know the length of the input buffer is 60. so 29 plus 60. and we'll get 89. last time we got 90 this time we're getting 89. now we're going to do 89 mod 60. we're doing the mod the length of the input buffer again 89 mod 60. now I can tell you right now it's going to be less than 1.5 because 90 was 1.5 and we're starting with a smaller number but dividing by the same so let's do 89 divided by 60. now it's 1.48333 it doesn't matter what that value actually is remember it's the remainder 89 minus 60 60 goes into A9 one time with a remainder of 29 left over so we can say equals 29. now you may have noticed that we keep getting the same number here so whenever we do the curtick minus the index we get a value at the end it always seems that we end up with the same value and for the most part that is actually true you can see yes this is we're getting the same value why are we doing these addition and this modulus so let's take some of this out let's say curtick is actually zero say we're on the first frame of this new second and let's run through this again now so let's say we have kurtick which is zero minus and let's say we're on frame 13 of this for Loop 0 minus 13. equals negative 13. well negative 13 is not going to be a valid index in our array but it should still relate to a value within our input buffer so what we can do now is continue along and we can instead add the length of the input buffer which as always is 60. and from that we will get a positive 47. now that is an index in our input buffer and it makes sense too because if we are to go from 0 and subtract 13 then we would get to index 47. after reaching the beginning if we start back at the end and take 13 units we would go back to unit 47. so if we do mod 47 by 60 . the remainder we get is going to be 47. 47 can't be divided evenly by 60. so we get the whole remainder of 47. so it's still valid with the modulus all right at this point we have our friend to check logic so now we just have to implement it if you haven't already our for loop with our last index comes out and we take curd tick minus the index from here we add the length of the input buffer then we perform modulus from the addition result and the length of the input buffer this value we're setting frame to check you might not have that's another local variable that I made so correct sequence counter is a local variable it's only available in this function this Frame the check we only need right here so we also only need it available in this function I simply made a new local variable that was an integer that I called frame to check and set it here this is the only place that I set it it is zero by default and will be updated every Loop iteration so that we know what frame we need to look at next from there we can actually get the data of that frame because we have this Frame history now now we can go ahead and plug this in and actually put this where we want it so I'll clean things up again you can move it with me while I do it we don't have all this stuff floating up above so let's organize something this Max frames between inputs we weren't using it before so we never had any reroute nodes let's go ahead and address that this will look a lot nicer and then additionally just make sure that nothing is overlapping here where you can't see it we look pretty good there's one other node here that we're going to want to clean up but we haven't gotten to that point yet so now after getting the frame to check and getting the value from the array of the input buffer based on that frame to check we can continue so make sure you drag off your input buffer type get this time it can just be a copy because we don't set anything we don't actually change any of the values of this one that we grabbed we're just checking against it it's already history it doesn't it's not the current frame it's not the current data for the frame it's just a check that we're doing to grab the data that was on that specific frame we don't need a reference we can just use a copy which will be quicker in this case make sure after getting the frame to check you plug it into the for Loop that was already here the for each loot with break and this is the main for Loop where we actually do the checks for each of our inputs in the input buffer against the inputs within the command you'll know this is the correct one because there will be a execution line an execution line which is the white line here coming from you know start command wherever else it has a few points actually and it comes all the way back into this for Loop and goes into the break once they're connected we were checking to see if our correct sequence counter was less than the maximum that way we knew it was a valid index we still want to do that but doing it this way won't work anymore because remember what we just talked about with the frame to check we're now reversing the way we're going through the input buffer so instead of going from zero to the maximum we're going from whatever index we're at and decreasing so just checking by addition won't work anymore instead what we need to make sure is that correct sequence counter is greater than negative one if it's greater than negative one we know that we haven't found a command yet and we can continue to Loop now the correct sequence counter addition the new result essentially for the correct sequence counter was being plugged in to get a value at the input buffer but that is also being replaced you can see mine is actually not connected anymore the get that we just got off of our frame to check is actually what's going to be plugged in here to the next break input info right before the is input and multi-input command you don't have to plug it in right now if you don't want we can do it when we get to that point but just know you can get rid of this correct sequence counter plus less than and the input buffer length you can additionally get rid of the input buffer get here check to see if the correct sequence counter is greater than negative one there we go so the F input info that we're actually using to check against if the input is pressed if it's released or if it's a press when it was a hold that is now coming from this Frame to check get and not the input buffer get at the index now we're not using anything from this actual input buffer Loop here as far as the element or index go but we still need to make sure we Loop through every single input buffer element because we do need to make sure that what the player is pressed is being taken into account we have our balance check here with our correct sequence counter we have one other check here as well that I've added that wasn't here before so previously the balance check led directly into the is input and multi-input command if it was found to be true but now we also want to make sure that the F input info here that we're using for all of our checks is not equal to none if it is equal to none we want to just skip it we don't want to do anything with it remember that a lot of our inputs in our input buffer will be none because on tick that should not mean that the player is penalized because they obviously cannot press 60 frames per second accurately they're not a machine so we want to just leave it alone we want to actually skip it to get this node by the way you just drag off the F input info and type not equal or exclamation mark equal and enum and then just leave it at none and then bring this into a branch only if it's true from here will we go into the is and put a multi-inbook command otherwise we'll just leave this logic alone there's one other step here that we need to do and that is if the correct sequence counter bounce check fails we had a false the false was resetting the correct sequence counter back to zero but of course we don't want to do that anymore we now want to set it to the length of the input types array so just like we did at the start here where we had the length of the input types array -1 and setting the correct sequence counter to that I have a reroute node for my inputs array right here and if we follow it I use that to get my length minus one and set that to the correct sequence counter it's no longer being set to zero so I'm getting rid of the zero and I'm setting it to this instead now the rest of this is the same until we get over to the next part where we set the correct sequence counter back to zero this time we were setting the correct sequence counter back to zero because the player had pressed an input that was incorrect for the command which led us to this false branch and then it turned out that it was not the released status meaning it was a press or a hold either way this means the player pressed the wrong input to perform this command in which case we were setting it back to zero but of course we don't want to set it back to just zero anymore instead we're going to set it back to our length minus one put this in here and we will clean this up just like that now for the length it's pretty obvious where it's coming from at this point but notice this is the same array from the F command info at the very start of the function we're using this inputs array so if you follow my line that's what is plugged into the length here just bring it up some way where it looks relatively neat following down the other branches here we were checking to see if this was a chargeable command or a multi-input command if it was a multi-input command and we had found that we released it we were setting the correct sequence counter to zero and one final time we have to do what you'd expect and instead of saying it to zero we set it to the length minus one and use that instead so I'm getting rid of the correct sequence counter being zero we actually already had the length here as you can see I was already using the length here because previously we were checking to see if the correct sequence counter plus one was equal to the length of the command input array so I'm using that same length here subtracting one from it and setting the correct sequence counter it would look something like this assuming I actually put it where it was supposed to be and then I just brought that into the same logic that we had before so essentially everywhere set correct sequence counter with zero we're just setting it to the length of the inputs array from the F command info structure minus one and setting that to correct sequence counter now last thing we need to do is here so assuming this first branch that we had after the first is input and multi-input command check is true that is when we were increasing the value of the correct sequence counter but remember we're now trying to go in the other order so instead of going from correct sequence counter of zero to one if we're on one we should go down to zero instead we're actually trying to reach negative one with our correct sequence counter right now that's how we know we've matched the number of elements in the sequence so where we had correct sequence counter increment equals equals the length we don't need to do that anymore we can get rid of that instead we want to do this right here which is correct sequence counter minus minus or decrement and equals equals negative one and if that's true that's when we call start command if it's false we bring it up here and it goes into the break just like it always has then here at the very end we were calling start command which was triggering the actual command nothing has changed in here so this is all the same then we were clearing the input buffer and we were setting the correct sequence counter back to zero we actually don't have to reset the correct sequence counter anymore with the new method that we're using and we don't have to clear the input buffer anymore either because the input buffer is now going to be the same size it's going to be 60 elements the whole way around so I'm going to get rid of these two nodes and I'm going to make sure start command does go into the reroute node that goes to break the for Loop that I mentioned earlier so make sure that's still happening all right guys time for the final recap because this was a very long episode so we're gonna go into check input buffer for command in which case we're going to check to see in each command if the elements of the command actually match what is in the input buffer to do this we set the correct sequence counter up to the maximum number of elements in the inputs array we get the data from the command such as the type status and required charge frames then we determine what frame we're currently at for this second and that will allow us to determine what frame to check based on how many frames these buttons can be pressed apart and still be considered a successful command press by checking that element in the input buffer we can then make sure that we are in the bounds of the command so we haven't gone past the correct number of inputs somehow or more importantly that we haven't met the actual requirements to perform the command thus we should still keep searching if that is the case we want to go and make sure that it is not equal to none because if it is equal to none we don't want to count it against the player most likely they just didn't press any input that frame and that's not an issue it's still a valid frame it's still useful to know that they didn't press anything on that frame then we do all of our standard checks that we covered in other episodes so for how we want to perform every single command and command type that we have and then if we get a correct press we decrement the correct sequence counter and if it is equal to negative one we know we have now reached the part where we've pressed all the correct inputs to perform that command so we should start command one final note here is about this for each loop with the input buffer I mentioned earlier in the episode that we wanted to keep it to Loop through the elements in the input buffer but I've since realized that we actually don't need to do that at all because we will have the direct element from the command that we are checking against right here it is now coming from our frame to check variable so we can actually remove this for Loop entirely since we aren't using anything about it and we don't even need to do the break anymore either technically you'll get the same result whether you have it in here or not I'd get rid of both of these after disconnecting it and then I'd also get rid of the reroute nodes that went from the ending of any of the paths into the break section of the for each loop with break anyway guys that's all I got for today so thank you so much for watching I really hope you enjoyed and if you did please subscribe there's more for myself in the channel than anything else you can do and I just really appreciate it I'm gonna give a huge shout out to my YouTube membership and patreon members and supporters thank you guys for all the love and for all the support you do give glad you're enjoying the series if you had any issues with this tutorial or any of my tutorials feel free to join the Discord Community it's completely free and anyway guys that's all I got so thank you so much for watching I'm Sean the bro and I'll see in the next one goodbye guys [Music] [Music]
Info
Channel: Shawnthebro
Views: 672
Rating: undefined out of 5
Keywords: Shawn, the, bro, Shawn the bro, stb, how to make a fighting game, unreal tutorial, unreal engine 4, ue4, unreal engine, unreal, engine, tutorial, c++, make a video game, make, video game, game, make video games, shawn thebro, fighting game, fighting, fighting game template, template, unreal engine tutorial, ue4 fighting game tutorial, input buffer, input, buffer, command, unreal input, input buffer ue4, combo, combos, special attacks, blueprint only, blueprint, only, input system, sys, ue5, par, 5.0
Id: r0IMFi102iE
Channel Id: undefined
Length: 50min 39sec (3039 seconds)
Published: Fri Mar 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.