GameMaker Studio 2: JRPG Cutscenes using Sequences Part 1/2.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay hello game makers this is game maker rob and today i'm going to show you part one of creating a jrpg uh cutscene using sequences in game maker uh this episode is gonna be mainly me talking about the reasons why uh i did things and showing it off and a little bit of code and then the second part uh we're just gonna dive into the code and uh build everything you know uh that you would need so uh right now the character is in like a main room and what we're gonna see is we're gonna be going to the same room three times and the first two times we're gonna see a different cutscene play and then the final time uh there's gonna be no cutscene because our story point has gone beyond that i'm basically using a global variable and inside the sequences i'm using a moment at the end of the sequence to just run a script to increase that value by one um and then i have an array storing sequences uh based on the rooms uh based on different story values and that's how i know that's how the game knows uh what to play so anyway let me show you this now uh press f5 this is the first sequence uh one thing i didn't show you is the player can move uh you know before and after sequences right now uh i can't move um this is uh talking text and right now the sequence is paused which is one of the main reasons i used objects over sprites so the sequence is playing again after i press enter space and now this first sequence is finished i can move around as the player if i press f5 and back to the start room i can move around go back to the thumb room this is the second sequence i can't move right now let's get through the sequence and there we go so uh that's the second sequence i can i can move again go back to the main room back to the throne room and then this is the same room but uh because there is no sequence in the array entry for this story point and for this room then no sequence plays so um why and how i made the sequences so i wanted to have interactive text boxes which means that i needed to pause sequences whilst waiting for player input and when a sequence is paused any animating sprites within the sequence also pause which was one of the main reasons i decided to use objects inside sequences instead of sprites the next thing i needed was to make the objects change their sprites when they change direction or want to do some other kind of animation for example uh broadcast messages was the best fit for this as you can send a string to an object and then have that object do whatever you like based upon that string i'm just using one single object that takes all of the broadcast messages and then that object you know tells all the things what to do basically i can use the same messages from using broadcast to stop and start music uh play sound effects uh have the screen shake uh change the font in talking text and anything you can kind of imagine you know uh you can do through strings so broadcast was really useful for that um i also used moments which allows you to run a script but you can't pass any arguments which is a bit of a bummer so i used moments to increase the story value like i said which is part of the reason how the game knows which cutscene to play and uh i have a 2d array uh with uh it's as long as there are many rooms and there are as many entries in it for as many story point stars are as well i just have every entry as a default of minus one meaning no cutscene and then manually overwrite it so it knows which cutscene to play um what i didn't tackle uh potential problems you may face i couldn't find a good way to tackle depth in sequences uh in fact i didn't make much of an attempt at all and it probably won't even be an issue for you if all your sprites are the same size of the tiles it's only if you have something like uh in this demo where the the sprites are taller than the tile sizes i also don't account for the player not being in the correct tile when activating the cutscene what if the player is facing the wrong way too my idea to get around this would be to have some code run in between touching the cutscene activator and the cut scene actually playing but like i said i did not uh tackle that uh sometimes even though i foresee problems i don't tackle them because i think it's uh extra complexity which isn't always needed for you know for many people so that's the main reason and my final thoughts uh sequences can be a really useful tool and if you take heed of the limitations of this tutorial uh the way that i show you should allow you to have dozens hundreds of cutscenes easily it's uh cut scenes are not something you just want to add on at the end though unless you really have to at least be thinking about how you will implement cutscenes from the start of making your game even if you don't make them straight away so um now we're gonna get on with uh making a sequence of some codes and uh part two will be out next week okay so i'm going to start by showing you the sprites that i have for the characters here is the player uh we have a down animation and we have left right and up and in the same for the npc he has down left right knob and then we have a text box for the text uh using nine slicing uh you don't have to use nine slicing i just decided to do that way um we have a sprite for an object that's going to detect when the player is over it or actually the player is going to detect it and that's what's going to trigger a cutscene you don't always have to trigger cut scenes like that it's just how i'm doing it and then we have a sprite for the throne room and uh the size of this sprite is 237x316 and as you can see my room uh i've made the width and height of the room the same as the sprite just to make it you know easy to deal with i don't know why it's any easy to do to deal with though anyway i'm also using a viewport so enable viewports visible um and again the same width and heights of the sprites and i'm just timing that by three to get every port to play with and i think that's everything for the setup and the next thing we're gonna do is make two objects obj player obj npc there's no code inside them all i've done is given them an appropriate down sprite so this is the player this is the npc and the next thing we're going to do is make a sequence okay so now we're going to make a sequence hopefully you can see this in the video yeah cool so i'm gonna call a sequence throne room one and then i'm just going to drag in the sprites for the throne room uh this point here is the zero zero so i just want to make sure that the origin for this sprite matched up there as well click it there there we go awesome and then uh so for this to work for us the code seems to work seamlessly uh the the actors need to the actors in the room which we're gonna add in a minute need to be in the same position as they start in the cutscene so um i'm gonna put the player down here uh he wants to his position wants to be one one two two seven two like that and then the npc wants to be up here uh let's check the position one one twelve nine six that's perfect and then uh in the room itself i'm gonna again place those same characters just check his you know 112 96 for this guy and for the player 112 272 awesome i'm using a grid size of 16 which matches the tile size and i'm using snap to make positioning easy so basically in all in every sequence i'm going to do today this is going to be the starting position of the uh npcs and the player um we'd want the player to start facing up but um we're going to tackle that in the sequence so that's not to worry about i mean if the player had just moved into this room uh you'd assume he would be facing upwards but i'm just gonna no i'm not gonna assume that i'm just gonna use code to make sure he's facing the right way so anyway uh let's do something with the sequence now okay so uh i'm gonna do i'm just gonna have the player walk up towards the npc and what this is gonna be a test for is just to make sure that um after the sequence is done um even though the player hasn't moved the character themselves uh we want the player to end up wherever wherever the cut scene finishes so that's what we're gonna do now so uh what is well the npc only started there that's not good i made a mistake placing npc let me just uh delete the npc no it needs to delete i'm just going to drag it down here and then delete this key oh it's wrong thing nevermind let me just delete the guy and uh make sure the track is starting at the very start and then drag him in still not 100 with this with sequences there we go cool let me just do a test and play the sequence from start to finish awesome i'm going to make the sequence double length because uh i want the player to walk all the way to the top so now i'm going to make sure all of our tracks extend to the full 120 so i'm going to right click and stretch for the npc right click and stretch for the player right click and stretch for the throne room um we don't need to display the throne room during the sequence this is just for making sure we have things in the right position and also uh right clicking and using stretch is a lot safer than just dragging and doing this because you can miss like the last few pixels or something so it's just safer to stretch it like that anyway so uh what one what we want is at the end of the sequence we want the player to end up here so i've just dragged him you can see one problem with with the way uh sequences work right now is uh depth order is based on the order of reactors so right now the npc's drawn over the player so we're just gonna move the player to the top track to avoid that this isn't a problem if you have sprites that are the same size as the grids but if you're using sprites like this uh then it may cause you some issues you have to get around but this is one way to deal with it oh that was a mistake uh there we go all right cool all right so now if we play the sequence we should be able to see the player move upwards there we go it's fine he's moving backwards the thing with uh using objects in sequences is uh he's always just gonna uh be using uh the sprite that he started with we're gonna change it using broadcast messages but not yet so anyway so this is our sequence right now so if we let's just go into the thumb room we're going to make a new object of course you're gonna add an object okay so all i've done is i've added uh an object called obj activate cutscene this one here and it needs uh the sprites activate cutscene sprite so you can see it and in the front throwing room i'm gonna place this asset here so the the play is gonna start with collision um i have tested it though and it doesn't matter where you place it as long as the play moves into it uh whenever the player finishes moving to that tile it's gonna activate uh but we're gonna have to do some code now so let's get into that okay so uh i have just used the bare bones of code just for now just to show you how override is going to work before we get into the meat of everything so in the player we have a step event all we're going to do is we're going to check for collision with the cutscene activation object um if there is a cutscene object we're just going to destroy it which is going to run that cutscene objects destroy events and then i'm also going to allow the player to uh move left and right with the left right keys so you'll see how that works in a minute um yeah and then in the activate cutscene object in this destroy event um this code is gonna be very similar to the uh final code we're gonna use in another object but for now let's just put it here so um all we're going to do is when this object is destroyed we're going to create an instance of our sequence using this line here we then want to know okay what objects does this sequence have inside it so to do that we have to use this function to get the sequence instance and then we have to use sequence get uh to be able to get the objects which is going to give us an array and then we're going to go through this array entrop entry by entry uh to get the object and then um when you first creating the sequence the objects for that sequence don't get created straight away i.e that step so right now at this point here uh the sequence objects haven't been created so even if an instance of the object exists that means there must already be one of them in the room then we're going to use instance find to get the first instance of the object which presumably is going to be the one that we want to override with ie obj player something like that so get the first instance and save it inside this variable and then we're going to use sequence instance override object to override the sequence object with the room object this might seem pretty complicated for what it's supposed to do and you might wonder why we're doing it here there's a couple of points so if you check the manual page for sequence instance override object you'll see that um you cannot override objects uh before the sequence has started to play uh you can't override uh the objects um beforehand you just have to have the sequence you have to have an instance of the sequence created and then before that plays you have to override them so uh it's a little bit more complicated than i would have liked but uh the other thing is well uh the reason why we because we know which objects are in the sequence right we can just you know just like type them you know override this object with this object but what i'm building is code that should work for you regardless of what objects are in what sequence so that's the point of making it a little bit more complex because you know in an rpg you're not just going to have a few cutscenes you're going to have you know 10 20 30 so the point being as your game scales this code doesn't get any harder at all it should be the same it should work the same okay so and now we have done that let's run the game make sure we can see this in the video there we go cool so uh as you can see um the sequence is played i can press left and right and move the player so this is you know the sequence is done now it's it's uh it's not working anymore but i can now move the player um if i run the game again i'm gonna mess with the controls while the sequence runs and you'll see why we need to stop the play so oops let me try again i wasn't ready so you can see that uh there's a lot i can wiggle the player while he's moving so um we're going to be using a state system so either the player can move or we're playing a cutscene and i would highly advise you to uh not have a separate state system for the player uh and for the game um and even the code i've done i've can realize you know what uh one state system could have worked for everything um i'm just in the habit of making different state systems for different objects but um really the more you can use one state system for everything it makes things a lot simpler so uh now i've shown you how override works we're gonna get into uh the rest of the code we're gonna build something from scratch using some of the code we've already used but uh the end point like i said is we'll end up with something that will scale really well uh no matter how big your game is uh
Info
Channel: GameMaker Rob
Views: 948
Rating: undefined out of 5
Keywords: gamemaker, game maker, gamemaker 2, game maker 2, gamemaker rob, gloomytoadstudio, samspade, spalding, jrpg, cutscene, sequence, sequences, how do I made a sequence, how do I make a cutscene using sequences, rpg, make a cutscene, make a sequence
Id: n3LPuskJRpI
Channel Id: undefined
Length: 20min 52sec (1252 seconds)
Published: Fri Aug 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.