UNREAL ENGINE 5 - QUARTZ CLOCK SYSTEM: Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up everybody welcome back to the channel Fuller here and in today's video we are going to jump into the quartz Timing System in the Unreal Engine 5.1 and I'm going to show you a little bit of what we're going to be working on today so we got our basic first person shooter when we pick up this gun it's going to start the percussion quantized then over here when we walk in this trigger box it's going to trigger the flute track quantized when we TR when we come over here it's gonna trigger that flute track off with the slow Fade Out and then when we go in this box it's going to completely shut all the music off and then we're back and okay so now the court system in unreal is a little complicated and it's a little um it takes a little bit of finagling to set it up but once you get it set up it's a really powerful tool because what it allows you to do is it allows you to play audio at sample accurate moments in time meaning you can trigger all sorts of things to happen exactly when you want it to happen and Dan Reynolds has a killer video out there on what quartz is and exactly how it works I'm going to put a link to the video down in my comment section so you can go check that out but he really does a cool walk through and explains exactly that quartz is actually a scheduling system is basically what it is and what it allows us to do is instead of just playing random you know music and hoping hoping that it's synced up what quartz does is it ensures that when you start this track it's going to be sample accurate and it really gives you a lot of cool opportunities to do some really procedural music in ways that you couldn't do before so let's jump on into the session and let's get started so in today's video we are going to create a quartz clock system we are going to use that clock to cue and play sounds at a specific quantized boundary and we're going to use trigger boxes to turn those on and turn those off with quantization so we're talking about musical rhythmic quantization so let's start I'm going to show you real quick the blueprint for this just so we um for those of you who want to try to just jump on in here's how you create the quartz clock here then down here I have some trigger boxes triggering a percussion track and a flute track and then I have a trigger box stopping it so we're going to build all of this from scratch so let me just do away with all of this okay clear out this blueprint okay so we're here in the level what I did all you have to do is basically go create a new game from the first person shooter perspective and when you load it you're just going to see this gun floating in the air and what I did is I put another trigger box uh right where this gun is that we are going to use if I can select it here if that we're going to use to trigger the actual um original audio and we're actually going to use this trigger to start the clock um and I'll explain that in a minute and then we're going to use these three trigger boxes uh to do other things so you don't have to um you know you can use just the basic whatever world you want to use but what you want to do is you want to go into your game you want to add uh three trigger boxes and one trigger sphere right here and that's really easy to do and the way to do that is you can just come over here under Place actors and type in trigger and then you can drag the trigger boxes in and you can drag drag the trigger sphere in put it wherever you want it move it around you can resize it with scale whatever you want to do so just drag three of those in and uh you can see here I got one two and three and then we'll be Off to the Races so once you do that we're going to go to our blue oh and let me show you the sounds we're using we're using this percussion layer here which is um just a percussion track kind of like a cinematic percussion track now uh coincidentally this is at 93 beats per minute and that's important also this flute track is also at 93 and I'll just play a little bit of this stump so this is just kind of like a flute um riffing on some cool like kind of vibey Middle Eastern Vibe with a ton of Reverb those are those do um those are at the same tempo and that's important when when when when using the court system just understand that you need to make sure all your audio is at the right at the same tempo otherwise it can get a little messy for the flute we're actually creating a meta sound so we're not just using that audio but we're creating a meta sound with the flute asset in it because I want this um I want the gain for the flute separate because what I want to be able to do is I want to be able to turn up and down the flute track when I walk in the trigger box and and um kill all the music when we walk in the stop music so let's get started the first thing we want to do is we want to go to open level blueprint and that's going to bring us in here right now there's really nothing in here uh as you can see empty blueprint so first thing we're going to do is step one create the quartz clock now the the you have to pull in the quartz sub system and create the clock and then that clock becomes the master for all of your events and that that that will be that will use that will be used to sync all of your quantize events so let's jump in here so first thing we want to do is we want to right click and we want to um get the quartz sub system so we're going to get Quartz subsystem and that's going to bring us right here so what this is doing is this is actually implementing that we want to use the quartz sub system from the subsystem we can create all sorts of clocks but today we're just going to create one clock so what we want to do here is we want to drag off here and we want to type create clock we're going to create a new clock so there's our new clock and we want to do this on event begin play so as soon as the game starts we're going to create we're going to access the quartz subsystem and we're going to create this clock now we want to name this clock I'm going to name this clock Main uh clock 93 and I'm just putting 93 there because I do want to be able to quickly reference the fact that this clock is at 93 BPM now you know you can change the quartz clock in the middle of a game you can change the tempo but for this we're going to keep it at 93 so I just like having the tempo in there so I I know which clock is which so we're going to create main clock 93 and then in settings and this is where we're going to pull off here and we are going to make quartz clock setting now if you have context sensitivity on this is about the only thing you'll be able to pull in we're going to make quartz clock setting then over here you can see we're going to pull off time signature and we're going to make quartz time signature for this we're going to leave this at 4 4. you can put that at whatever you want but for this for these tracks they're all four four um and that they're they're at 93 beats per minute so the other thing we're going to do is we're going to come over here we're going to pull off this return value and we're going to set BPM set beats per minute and that's going to automatically connect these two execution nodes now we want to type here what our Tempo is going to be this can be anything but again my audio files are at 93 so it makes sense to trigger them at 93 that way we can bring those audio in on Beats 16th notes 30 second notes whatever you want to do um so now that we've got the um BPM set up the other thing I want to do is I do want to come over here and I want to promote this to a variable come over here I'm gonna call this main clock 93. so now this is going to uh and you see that this defaulted to um oh wait I won't let me do that delete there we go so you can see over here this defaulted to the type of quartz clock type so this is a variable so now this variable is going to be storing this quartz clock now that's all we need to do for now but keep in mind we've created the clock but eventually we're going to have to start the clock because once we start the clock that's when the timer starts so now this let's just comment this section out here this is going to be create quartz clock all right [Music] now now that we have the clock created we are going to use the trigger box to spawn and play a sound that's quantized so we're going to go back to our first person map I want to get this trigger sphere right here it's right outside the gun which is going to trigger pretty much right when we grab the gun as well um and we are going to go back to our first person map we're going to right click create reference to trigger sphere actually no we're going to go add event Collision on actor begin overlap so now when our character walks over that sphere it's going to do whatever we tell it so right now we're going to go out here we're going to bring this and we're going to add a do once node and the reason we want to do once is because we don't want it to trigger the sound every single time we walk through that sphere we pick up the gun once we want to trigger that sound once now once we stop the music we'll open that trigger back up so we can re-trigger it but this way while the music is playing it won't trigger it twice now I'm going to come over here we want to create 2D sound and for here we're going to select our percussion which is right here we're going to hit boom so that's gonna cue up the sound it's not playing it yet it's just creating it now we're going to come over here and off this we're going to drag play quantized and as you can see this is an option now and we're going to play quantized we're going to put this at the Target then under play quantized we are this is where we need the clock handle okay so here's the clock that we made we're going to bring this in we're going to get the clock we're going to put this in so it's now it's obeying the time of this clock and then in quantize boundary we're going to drag this off we're going to go make quantization boundary I want this to start on the bar when the transport resets so this is going to be relative to the transport it's going to start at the beginning of the next bar so if we cue this if we run into that trigger box in the middle of bar one and two it's going to start this audio right on B2 which you know essentially doesn't matter the first time but when we start layering the other tracks in it will matter otherwise they'll be all wacky and out of sync now the other thing we want to do is we want to expand this play quantized node I want to pull out in delegate and what we're going to do here is we are going to add a custom event and we'll just call this quantize let's just call this quantize and then under event type we're going to bring out this switch and this is really cool here this is going to allow us to um tell this that let's wait till this is queued once this is queued then we want to do something else so what do we want to do once it's queued we want to start the quartz clock all right so now what we want to do is we want to go grab our clock again bring that here we're going to get clock then we're going to start clock boom and we want to do this when this is cued [Music] so now once this happens and this sound is queued up we're going to start the clock and it's going to play quantized this will not play until we start the clock anytime you uh tie a vent to a quantization boundary it won't play unless the clock is actually rolling it's almost like a transport on a doll you could have your files lined up in your Daw but until you hit play you're not going to hear anything so now that's that let's go back and test this so let's compile save let's go back to first person hit play see what we got bam perfect so that's great it works perfectly so let's just do it one more time walk in here as soon as we pick up the gun you'll hear the percussion start and that's starting right on beat one of the clock now that's the first section now let's make a trigger box over here let's select this I'm going to go to our blueprint okay and you know what let's uh let's comment this out that is start percussion now we're going to come down here add an event on a collision event for this trigger box and this is the trigger box it's gonna turn our flutes on and so what we're going to do here same thing kind of we did up here we're going to go create do once create 2D sound we're going to play the sound quantized on the main clock and we're going to make a quantization boundary now we don't need the other stuff because the um clock has already been started so let's just go here here here and here let's copy this Ctrl C come over here control V we're going to start this do once now here we're going to select uh metasound flute that's going to start our meta sound as soon as we overlap this trigger box we're going to cue up the sound and play it quantized to the um next bar so that's all we need to do let's watch it work oh you know what one thing else I want to do I want to do a print string here and I want to just print uh flutes are triggered bro I'm so triggered okay so here we go let's go here now we're gonna now here's the thing if we go to here first it says flutes are triggered but they are triggered but they're not playing why because we haven't started the clock so we go here we pick up our gun bam clock has started now the flutes are starting why because I already had the sound queued up when I went over the trigger box and since I started the clock it started exactly the same time as the percussion but let's do it the opposite way let's go pick up our gun bam you hear the percussion no flutes yet so when I walk into this flutes on it's going to start it it's gonna give us the trigger message but you're not going to hear the flutes come in until the next bar right here watch this that's the bar right there and you see the flutes started perfectly on top of that bar and is now in perfect sync now uh don't be confused because the flute if you recall the flute audio doesn't come in on the downbeat one two three so it comes in on the one it comes in on the two so you hear it coming on the two but it's actually playing on the one one more time pick up the gun then we go trigger the flutes one two three four trigger there it is perfect now let's turn them off how are we going to turn them off what I want to do now is I want to um so when we come in uh this trigger box we start the float uh but I mean the we start the fluid track but now what I want to do is I want to go I want to do a end overlap but this time what I want to do is I want to send a float parameter uh to The Meta sound so oh oh you know what else I want to do check this out so I want to um on this return value here I want to set a variable I want to promote this two variable um and I want to call this variable here let's just insert this right here so when we oh gosh C plus plus killing me all right hold on I do that a lot all right all right so I want to come in here I want to drop this in here because what I want to do is when we cue the sound I want to set this variable uh we want to call this flute and this is an audio component variable so now what's playing is going to be stored in Flute so now what we're going to do is we have access to this meta sound here so what we're going to do over here on the end uh overlap we're going to bring in flute and then we're going to get flute and we're going to set float parameter which you should remember from our meta sound 101 tutorial now we can go in here and what's the name of the parameter remember we call this flute gain so this is going to say flute gain so now when we walk over this box that parameter is going to change to zero so if the volume's at one which is full it's going to go to zero which is none so what we'll have when we walk in and when I walk out it'll go to zero but that's useless so what we're going to do is we're actually gonna get rid of that and we're gonna put it on this box that's what I meant to do over here I want to put it on this box which says flutes off so I want to select this one go in here I want to right click uh Collision actor begin overlap and I want to drag this out so now when we go over to this box it's going to turn on in this box it's going to turn off here we go percussions triggered clock is rolling one two three four triggered we got the flutes on now we're gonna go in here and the flute track will go off now that's a little abrupt so what I would do here is I would um set a trigger float uh timeline and so the way we do that again we're just going to lurp that we're going to go a timeline we're going to add a timeline this is going to be real quick we're just gonna call that lerp uh we are going to set this uh we're gonna add a float track and I did this in one of my other videos uh we're gonna create this will be one second in length uh and then we're gonna add a node here I'm going real fast here because I did this in another video I can't remember which one I think it was my uh steampunk uh monosynth one go one so right now this uh this is gonna take us from zero to one so that timeline's good uh then we'll go back over here now what we want to do is we want to trigger this time line lerp and we are going to update the float parameter but the way we're going to do that is we're going to interp that uh to oh no that's not what I don't know we want to enter we want to alert we want to alert that we want to lurp that from zero we want to alert that from one to zero and we want to do it over the course of the timeline so now we are going to when you overlap the second trigger box it's going to slowly well within one second it's going to go from one to zero so it's going to turn it down a little more gradual that's going to be a lot smoother for us so let's check that out trigger percussion flutes are triggered [Music] now now you'll hear it slowly Fade Out that's what we want super smooth super chill now we did do onces so we didn't re-trigger stuff so what we want to do now our final step and let's just um this is all part of the flutes so let's just make this all part of the flutes we're going to comment this out let's call this flutes the final step in this uh tutorial is we want to make it so that when we walk in this box it just turns everything off and the way we're going to do that we're going to select the trigger go back to the blueprint up here I'm going to right click on uh begin play now what I want to do is uh I want to oh did I put a variable up here um you know what let me add a variable here as well so um we want to go here and I uh do want to uh I did this in the last one let me delete this that's left over from my last time I want to go over here I want to set variable promote to variable I want to call this one percussion so now we have access to that wherever we want it and we don't get a super sloppy graph um and then we'll come out here so now we have the percussion variable just like we have the flute variable so up here what I want to do is I want to bring this in the flute get flute I want to bring in percussion I want to get percussion now we're going to drag off this and we're going to press we're going to type in stop now we could do this smoother with volume but right now I just want to kill the sound so now we're going to go Target there so when we listen to this no matter what's playing when we walk we could have that we could have flutes playing when we walk into this box it's going to shut everything off bam and that's what we want now the other thing we want to do is after it shuts everything off we want to come down here we want to do a sequence node and then we want to bring this here and I want to on this I want to reset basically open this do once and then where's the other one oh the other one's up here so let's bring this up here and then I want to open this do one so now what this is doing this is resetting those other trigger boxes so that when I go back to them they'll start the music again so music flutes on music off but now our clock is rolling so we can turn the flutes back on with the percussion track and again that cycle will repeat over and over so that's the introduction to the quartz system I'm going to do more videos of about specifically around the court system we're going to get more and more complex uh in each video and eventually we're going to build a completely interactive music system with all sorts of cool things that you can do for interactive music quartz opens up a lot of possibilities in unreal five and it's a really powerful thing so it's really worth taking some time and learning how to do it learning how to set up the clock and grab the clock and all that so that all of the actors and stuff in the world can interact with the music and Trigger quantized events so hope this video was helpful thanks so much for checking out the Channel please like And subscribe if you get a chance and we'll see in the next video
Info
Channel: Brian Michael Fuller
Views: 1,718
Rating: undefined out of 5
Keywords:
Id: wefcc18ujXE
Channel Id: undefined
Length: 24min 10sec (1450 seconds)
Published: Wed May 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.