CUTSCENES in Unity using Timeline

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm going to show you guys how to build out a quick cut scene using unity's timeline system which allows you to animate game objects fart play sounds and transition smoothly into gameplay so this is a project I have for my five minute top down shooter tutorial right now the enemies just gotta chase around the player and I can shoot the enemy a couple times and it will die and drop something this is all irrelevant this is just the scene I have set up right now so let's go ahead and start making a cut scene I'd want to introduce these characters before they start fighting and so the first thing we need to do is actually get the timeline window open up to do that we can go to window sequencing and then timeline so we got our timeline on the bottom here and now the next thing we actually want to do is create a new empty game object and we'll call this timeline or you can call it cutscene manager or whatever you want but once you have an empty game object we can now select it in the hierarchy and you'll see in the timeline window it says we can now create a new timeline so let's go ahead and do that let's hit create we're now going to save this somewhere in our assets folder I'll just call this cutscene zero you can name it whatever you want and we now have something that looks just like our animation window it's very similar and if you have experience with animation or even editing videos this is going to be very similar in how it works essentially you can right click on the left and we have all these different types of tracks we can put in and then a track group is really just a folder to collect them all for organization but the first thing we really want to look at is the animation track because this is kind of the bread and butter tool you're going to be using and when we create one you'll see we have an empty animator slot we need to fill we can start with the player first so I'll click and drag our player from our hierarchy into this slot and when we do it'll prompt us to create an animator on our player if it doesn't exist already which it doesn't on mine so I'll say yes create that and it will fill with the player animator so let's keep this really simple for now what I want to happen is at the start of the scene I want my player to come in from the bottom following my mouse to walk up into the scene into a starting position so what we can do is hit this recording button and I'm on the first frame here on the timeline itself we can move through our sequence just like we could with an animation but we'll start at the first frame and we'll hit start recording and now selecting my player really what I want to do is drag them out of the scene maybe down to like negative I don't know negative 15 or something like that it's again this is kind of arbitrary and then skipping forward a bit we can reset this back to like negative three in the Y which is where the player was originally and stop recording okay so we have a point at the first frame which is our player off camera and then after in this case 180 frames it's going to move back to around its starting position if we play this timeline now we'll see that our player just slowly creeps into the scene and if you don't like working in frames like 0 to 180 you can actually hit the gear here and change some settings of the timeline itself so we can change this from frames to seconds and you'll see that we're actually doing this in a three second interval which maybe is easier to understand when you're working with this and so we can make this animation much more complex if we wanted to but I'm keeping everything purposefully simple and we have this selection here right of three seconds this is what's currently going on well what if we didn't want to play right away what if we wanted to move this and edit it as a whole what we can do is right click in this and do convert to clip track and you'll see it'll pop up as recorded we could rename this clip to like player entrance or whatever we want to call it right and at this point we can now actually drag around this clip on the timeline so let's say we didn't want our clip to start for a full second we could actually drag it over to the one second Mark and hit play and now there's an additional second added to our character walking up and this is really nice because you can imagine that right now we just have a single game object being animated but let's say we had 20 in our scene of all these different things going on well we can actually take clips of each of them and then we can just simply move them around the timeline as one whole and line things up properly and fine-tune things as we go along and in the case you ever want to edit what's happening in this clip you can simply right click and go to edit an animation window and you'll see just like a regular animation you can then tweak this one individually so if we play this animation you'll see the exact same things happening and you can actually move these keyframes around or add some new ones and that will still reflect back to this clip here so it's all really seamless and really easy to use so with that said let's actually go ahead and bring that back to the beginning and now I'm going to right click and create a new animation track and this time I'll go ahead and click and drag on our enemy and put them into this new animator slot and we'll say create an animator because I don't have one on him and just like before what we want to do is hit record on the enemy this time we'll go ahead and install like the enemy and I'm just going to drag him up out of the screen maybe to like 10 in the Y it doesn't really matter for me this is just an example and same thing I'll click on three seconds and this time I will then drag him back down into the top of the frame where I want him to be that looks fine with me and we can stop recording so now I can hit play and you'll see both characters come from out of the screen and meet each other in frame just like before I can go ahead and convert this to a clip track I'll call this enemy entrance and now let's say we actually want to offset these I could go ahead and drag this after the player entrance and when we play the timeline now we have our player come in first then it triggers our enemy track who walks in from the top so now this is definitely worth noting if we select on either of our clip tracks here and we look at our inspector we have a whole ton of properties we can now fine-tune including like the duration of the clips themselves which you can also do by just clicking and dragging on the timeline itself but you have other things too like the speed multiplier whether you want the animations to hold after they finish or Loop or reverse you'll notice on the player entrance since it happens at start there's no pre-extrepolate but there's things you could do afterwards such as Loop or ping pong which will reverse through the clip and then go back but if I click on enemy entrance you'll see the pre-extrapolate is to hold for three seconds because that's where it aligns in the timeline if we move this over you'll see the the value updates and so there's some interesting things you can do here that are I'm not going to go too deep into really you can experiment and play around with it as you see fit so what we have right now is if we actually play the game right our player comes in first I can't move around yet our enemy comes in second and then we get full control of our player and our enemy starts chasing I can go ahead and shoot so without having to worry about state or anything like that from the get-go and granted you could solve this with animation as well but this is just a nice easy way of introducing a quote-unquote cut scene before your game and something to keep in mind that if you actually have in-game controls you know they'll wait until the timeline finishes or if a timeline begins it will kind of put your gameplay State on hold in most cases which is really convenient so now let's go ahead and show some things you can do with cameras because right now when we actually hit play our players just kind of like walking off from screen right we don't really know what's going on so our main camera is set in the middle of this Arena that's fine I'm going to duplicate this and I'll call this player camera I'll duplicate another and call it enemy camera just for later and selecting the player camera I'm gonna go ahead and drag this down quite a bit so now I have a main camera that's set into the middle of the screen I have a player camera that's focused somewhat down right so this should capture the player at the beginning of the timeline before they start walking up and now I have this enemy camera I can drag up close to 10 in the Y and that will capture the enemy before he starts walking in as well and then let's select both the player and enemy camera and disable them so right now if you look at my game screen it's just focused on the main camera if we go to our timeline I can right click I can go to activation track and this will basically enable a game object in this case a camera and so I'll actually shrink the end of this track to about halfway through the player entrance animation we'll just see what that looks like it's kind of arbitrary and we'll drag in our player camera and then we can do the same thing we could create another activation track drag in the enemy camera and we'll drag it to the start of the enemy entrance and make it about halfway as well and so I think this is gonna actually look really janky so I just added these two squares in to help illustrate what's going on for you guys this is gonna look awful but if I hit play now essentially what's going to happen is it'll start on the player camera go to the main camera go to the enemy camera and go back to the main camera and then the game will resume like normal and both of the other cameras if I pause it the player camera and the enemy camera are disabled so looking at the Timeline the other cameras will only be enabled during these activation periods and because the main camera is always enabled that's just going to be like the default hopefully that makes sense so there's one more thing I want to show you with activation tracks I have two text objects that are exactly the same I just changed the color I have fight text red and I have fight text yellow and the idea is I really want to toggle these on and off so that it flashes which is going to be very simple when we can do this in a timeline so let's go ahead and I'll create two more activation tracks I'll drag in my fatex red I'll drag in my fight text yellow let's say after our enemy is in place we want to wait about a half second and then we want to flash fight for two seconds so what we can do is set the fight text red for two seconds and then for the fight text yellow we want to offset this a little bit right so you'll see I shrunk down the phytex yellow to be really small and what's going to happen is after the enemy gets it to place right we wait a little bit and then the red fight pops on the screen we keep going the yellow will pop on momentarily because it's just a short amount and then it will go back to red and the reason I'm doing it this way is I want to showcase to you that you can actually copy and paste additional versions of the same track so here I can actually make a few of these yellows and I can kind of space them out a bit right you can do some science to this so that it actually you know looks somewhat consistent so just by using copy and paste we now have several different instances of turning this fight text yellow on and off and it will give us this flashing effect right as we go along and I'm sure there are other ways to do this but this works well enough and now if we actually hit play you'll see it goes on and off like we want and so it's worth noting you can do this with any of these tracks right including our enemy entrance I could copy and paste this and now after our enemy moves back into place he'll kind of teleport back to the top and do it again right which we don't really want but that's to Showcase that you can actually replay these animations over and over again you don't have to feel like you have to redo it every time or anything like that so you can get the most out of each of these clips so anyway with this in place the last thing I want to do is now play a sound effect over this fight command and then once it's finished the game will begin more or less so I have this MP3 here called fight fight that's me can you tell so it's actually really easy to add any sound effect this is just an MP3 I'm just going to click and drag it underneath where the texts are going on and off and you'll see it automatically creates a audio track for us you could also right click and go to audio track but it did it for us and it placed the clip right here and so I'm just going to go ahead and Trigger it near the beginning of the fight text where it first appears there's a little bit of Dead Space you could drag that in if you wanted to doesn't really matter to me so let's go ahead and actually test this out we can try and Run the game we have our cameras changing just like we set up before it looks terrible I'm sorry they move into place it plays the sound it plays the text the game begins I can now move around and you'll notice the red text is obviously staying on screen which is not what we want so why is this happening in fact my two text objects here the fight text red and fight text yellow are disabled so this definitely should not be happening looking at our timeline you may notice we have this blue marker here at the end of our cut scene and that's exactly what it signifies it's the last frame available in our cutscene and even if we zoom in all the way right here we have our fight text red on and while it should be disabling at this last frame I don't think it actually is at least that's my running Theory so one thing we can do is actually adjust our timeline settings which again is this gear icon on the side we can click that and go to duration mode and right now it's doing based on Clips but we could also set this to fixed length and that now lets this blue line become adjustable so I'll click and drag it out I don't know five seconds or five milliseconds from there and we can go ahead and test this now now that there's a little bit more buffer room between the end of that frame so we'll hit play we'll see our cameras moving around it looks terrible again I'm sorry they move into place far away is the sound in the text and now it disappears as I expected and so I don't really know why this is a bug there's probably other better ways of fixing that maybe but that's a simple enough way for me I can now go ahead and play the game and kill the enemy and that's it we have a working cutscene to start off our game even though it kind of looks like crap you still get an idea of some of the tools available to you so that's the general idea I hope this tutorial helped you guys out and got started building your own cutscenes and make sure if it helped you you subscribe to the channel see you guys in the next one thank you
Info
Channel: BMo
Views: 22,785
Rating: undefined out of 5
Keywords: unity, tutorial, bmo, unity tutorial, bmo unity, bmo unity tutorial, unity cutscene tutorial, cutscene tutorial, unity timeline tutorial, how to make a cutscene in unity, unity3d, unity2d, unity 2d tutorial, unity 3d tutorial, unity cut scene tutorial, unity cut scene, cut scene, unity time line tutorial, unity cutscenes, how to make cutscenes unity, unity cutscene, unity timeline, beginner unity tutorial, lesson, game dev, game development, unity engine
Id: Ms10GAMAydA
Channel Id: undefined
Length: 13min 24sec (804 seconds)
Published: Wed May 10 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.