GameMaker Studio 2: Complete Platformer Tutorial (Part 14: Dying )

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody and welcome to part 14 today we're gonna be taking a look at having a bit of a game over sequence so when we touch an enemy we're gonna fall over that just in the exact same way that an enemy falls over when we shoot them and we're just gonna restart the room that we're in so I'll just demonstrate what the effects can look like we touch one of these dudes we kind of get a bit of a slow-mo we fall over and then just a few like a full second later I think after we touch the floor we restart the room that we're in okay it works exactly the same way it's just shooting these enemies do but we see the slow-mo is an extra thing we add to the top of that to add some drama to the player character you know the important one having been killed and we just sort of restart the room that we're in so mostly all this is doing is combining a bunch of things that we've already done before we create the animations the player we're reusing that we create the sound effect for that we've created screen shake for that before we've created the slide transition before that so it's just goes to show how we've been building kind of a set of tools that we can reuse to create all kinds of different things okay and that's what it's going to create on our final level is pretty impossible now because obviously if you touch one of these it's game over and they're just everywhere but we can fix I know later partner but let's go about seeing how we put this death sequence together all right so as I said before most of this is going to be created from stuff we already have so the first thing I'm gonna do is actually duplicate oded remember this is the dead object that happens whenever one of our enemies die it's called oh dad which seems kind of generic when really I suppose it'll be called Oh enemy dead since we're gonna have two separate ones and one for the enemies and one for the player but now you can even rename those as appropriately if you want but I'm just gonna call this Opie dead for play at that okay oh just I'm gonna keep things fairly simple so double click that and we just got an exact copy of our previous object you might window like oh maybe we should make this like a parent and child object relationship and create specific like a template for death objects and have the enemy and player won't be sort of a child apart but they're gonna be a little bit different in how they work so you know just in sort of surgical enough ways it's the best word I could think of this private thought a parent-child relationship wouldn't really work here exactly in the same way so I'm just gonna create a whole new object called Opie dad for this okay make sure this is one you've got open sometimes if you've got this open and you duplicate the object you might do make the mistake I make which is assuming your focus has changed and actually make changes to your original object so make sure you're making changes to the correct object object Opie dad I bomb here and don't change Oh dead the original so and the create event for this I'm gonna have to do a couple of little things before I do that actually let's just change the sprite from the enemy 2s player D okay yeah that's another thing I've created a couple of new sprites well now I've created one new sprite which is s player D which is exactly the same as this enemy D only I've changed the color of the shirt to match the player right because the are the same sprite ohyes okay so I'll leave you to do that that's pretty pretty straightforward piece of work so make sure you've got that sprite set up the next thing we want to do in the create event here is we're gonna write the line image and score index equals zero okay because we don't know what we're gonna do is we're gonna use the instance change function to change a player into oded okay that keeps the the instanceid the same we're just changing what object that instance is an instance of okay which is helpful for a few things but um because we're gonna do that it means we're gonna retain all of the variables and all of the sort of the well you know it's there all of the variables of a player okay so we're gonna be bringing along all of its like speed and direction and all that kind of stuff and because of that we're also bringing along its current animation frame and because we might be running with no idea what our image index might be so we're gonna have to read that 2:04 this otherwise you might finally start on the the second frame of animation here which is the one where he's lying on the ground which we don't want we want to make sure we start on this one so make sure when we run the create event for this we set image index back to zero okay a screen shake we're going to change that open rather than being 25 pencil period up to 60 okay just so it lasts a bunch longer because you know that for the player and all that audio plays sound s and F that can all be the same the next thing I'm going to do is under here I'm gonna write game set speed okay and this is kind of unique to game XT do too if you're following along with one point X you might want to do room speed I'm not sure if it works in exactly the same way a car remember but I know the difference between two and one point X is in one point X you adjust the room speed to slap solve a target frame rate for an individual room in this you set the game speed and that's the the game's current target frame rate at any point in time okay it's not room specific anymore so we're gonna set this to thirty comma game speed fps okay which is gonna set the game to be 30fps for the duration of the of this sort of death animation though we're gonna do okay so she's gonna give kind of a pseudo slow-mo effect this is the cheapest laziest and happiest way possible of creating a slow-mo effect it's very very simple very straightforward and probably a little super long-term and again especially if you ever want to do a lot more complicated things with your with your frame rate and fps and what's it called Delta timing and that kind of thing you might run into issues where you don't want to use this method for slow-mo anymore but it's a very good place holder well you know you're just getting things to work and getting things to look and feel how you want your game to be okay lots of other ways of creating slow-mo effects but there are a lot more complicating beyond the scope of this series so for now this will do is just fine the other thing I'm going to do is say with OU camera below equal the dot d the reason I do this is because well I think I could go back and change the original play a thing with the change of camera rather swallow to follow the player ID rather than just the player object but I'm not too sure all the consequences of that so I'm just gonna fix it here because in I believe Oh camera the start here in the create follow equal a player yeah so because this is just following the player object it just finds either that objects um it'll either return that object ID or no one depending on whether or not that a instance exists which is handy because it it handles the case of whether or not the object actually exists but because of that follow is gonna stop equaling this that that particular instance once a player stops existing because we're gonna change it into o P dead and so we want to make sure we capture that exact ie D there okay as I said could in theory I could change this to be like Oh player dot ID to make it work I said cuz then we're just carrying the instance ID in the instance ID is never actually going to change but it's handy having it like this just because as I say this will always deal with the fact of the player just still no longer existing because it's player no longer exists then this just returns -4 or no one so it works out okay so just to make sure that we get the ID of opie dead we're gonna change this to be other dot ided in here okay I'm just to make sure the camera follows this particular instance next up in the step event okay I'm going to come down to around here when we have a vertical collision and we set done to equal one this is part of a whole death thing when you land on the floor we sat image index to one so that we we've kind of finished the whole flying through the air nonsense what I'm gonna do in here is that alarm 0 equals 60 okay then 60 frames from the point that we touched the floor that's when we'll reset the room and reset the game speed back to normal okay I'll do that quickly now so add alarm' zero to the event list ropey dead and in here I'm going to write reset game speed and room game set speed 60 game speed yes okay assets our frame rate back to 60 and slide transition star transition script that we were in before trans mode go to and then their target oh so they're from caption go to comma and then the target will be just room which will return of the ID of the room are currently in so I'll just restart whatever room we're in okay and I think that's more or less all there is to it with this particular object now what we want to do is make it so we actually we create this we actually died when we touch an enemy okay so and go ahead and completely close this down now it's everything we need to do in there oh you think so let's now come to a player and add a new event for a player collision with Oh enemy ok description in this is just gonna be Donny kind of bleak and so on but that is what we're gonna do in here so with Oh gun we're gonna do instance destroy there might be all kind of things you want to do with the gun make it fly off or do whatever whatever you want we're just gonna get rid of it the reason we want to get rid of it because obviously when the player stop when no instance of the player stops existing like we don't we don't want the gun to still be pointing towards the mouse and all that stuff and and obviously trying to follow a player that doesn't exist anymore and all those kind of problems so it's easiest if we just get rid of it but you might find your own solution to whatever you want to do with it that's up to you and then the next thing we'll do is just instance underscore change which is going to change this particular instance of a player from being an instance of a player into being an instance of opie dead okay and we do it by typing the name of the object we want to change into which is ope dead and the next argument for this is a true or false Barrett boolean Homer said barian like a combination of variable and boolean a boolean which is a true or false variable for perform events which means whether or not when we change into this object we perform the create event for or not and whether or not we perform the destroy event for this instance and we want to say true to this because we want to perform that create event that's in opie dead okay whereas you can bypass that and so swap from one object to another but have it skip over to create events just simply by putting false into here that's when we use that very useful little function that because it allows you to carry all of our variables and all that kind of stuff along with along with the original instance that's not the only thing that we want to do in here however we want to do change change our direction around a bit the same way we do with enemies when they die we decide which direction they got hit from which direction they should kind of fly away from so we're going to do something similar here I'm going to say Direction equals point direction you notice we're doing this after the instance change so theoretically at this point this is now an instance of opie dead when this code is running it doesn't make too much of a difference but just something to be aware of a point Direction further dot x over being the other instance in the collision so the instance of Oh enemy over dot Y X & Y okay so the direction from the centre of the enemy object to the center of okay so that gives us kind of the direction that we've been hit wrong you might notice that's probably going to be a bit weird with the bigger enemies because the the center will be higher up so um you may feel like you're being hit down by them or whatever if you run into them on the ground and you get pushed down lower meds it's up to you how you want that to work but we're just in for learning this in a fairly simple way so you get the idea HSP is going to equal like the x6 direction the SP ecor1 the Y or direction - - exactly the same as how we did it with the Odin Oh enemy and Hopi uh Oh enemy and Oh dead when we created those okay just to give ourselves sort of a push in a big push horizontally and also a sort of a big push it's always somewhat up okay so thanks we're still focused in one other direction we were hit from so if we were hit from above we would still kind of go down but we kind of like sort of bias it and you put direction so we get that kind of move like like a little curve to our trajectory okay if sign HSP it's not equal zero image and scale equal sign HSP and that's just gonna make sure pointing in the right direction based on the direction we've been hit okay and that's everything there one other thing I'm gonna do I think I might forgot to do is an Opie dead in the create event I'm gonna set the gravity from North point three or Northpoint two just to give us kind of a bit more float again we want you on the sword death animation for the player to be a bit more traumatic so it's just gonna be a bit more floaty so we'll just reduce the gravity a tiny little bit there I think that's more or less all there is to do or that's all there is to doing the player object the one last thing I'm gonna do is I'm gonna go to the camera object and in the step event around here where we set our X 2 to be follow X and follow y what I'm gonna do is I'm gonna say if follow dot objects index equals okie yet so what that will do is it will tell us whether or not the object that we're following with the camera is that particular object which means we must be dead right there for this to exist at all and for follow follow to be that object the player must have just died right if that's the case I'm gonna set X to equal X 2 and Y to equal Y 2 which means we're just we're gonna skip the kind of easing of the camera and we're just gonna fix the center of the camera on opie dead just so that the camera always has it centered so that we're properly focused in on this element okay and that's it we should now have pretty much everything I do believe so we can run that now if I go to a game and I run into one of these we play the sound get a dramatic kind of slow-mo death and then act for a second the room restarts as well okay so these things die in the same way though colonies we die in that exact same way okay so as you can see all we've really done we've not really had to write much new code at all we've more or less just reused elements of things we've already created our slide transition are already existing dead object and so on we've just sort of used those tools that we already had and we've already read put them together to create an entirely new aspect of our game okay hope you guys enjoyed that and I will catch you guys next time thank you for watching a huge channel to all of my patreon supporters without whom you wouldn't be watching this video I wouldn't be making tutorial videos anymore without these guys a huge show out in particular and in no particular order to Louis R Pereira don't egg Ben Brandon Kelly Dan in a mule Chris maja andreas tabac gummy Taemin James grimly Charles Montgomery Harold Guidry matte coat Nathaniel Wolff NYX lavish Steven Hagen Michael Ward Jason McMillan Shana --then crispy Owen Morgan Xena and my bowels of the dog and Patrick Duffy thank you all for your incredible support and I'll see you guys next week
Info
Channel: Shaun Spalding
Views: 69,253
Rating: undefined out of 5
Keywords: Game Maker (Video Game Engine), Tutorial, GameMaker Tutorial, GameMaker, Game Development, Indie Games, Tutorial Series, Game Maker Studio, Making Games, How to make games, GameMaker Studio 2, GMS, GMS2
Id: d7ztOC4Jffo
Channel Id: undefined
Length: 17min 19sec (1039 seconds)
Published: Fri Feb 16 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.