GameMaker Studio 2 - How To Transition Rooms Beginner Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] greetings and welcome my name is Aaron Craig with be honest games and in this game maker studio 2 tutorial I'm going to be showing you how to change or transition rooms in your game using just one object and it is a very simple method it's going to look something like this you're going to have a player object that you can move around and a warp object that when you hit it you will transition rooms and go to a new location then when you hit that warp object again you'll go to a different room so I'm using one object that we are going to programmatically tell how and where to put the player each time they run into it it's super simple and it's super fast let's just jump right into it now if you want to do this follow along and just use those simple sprites make them on your own go ahead if you'd like to use a little more complex sprites you can download this project I've got fara here along with an object of sera that has her step code already set up if you're interested in looking at that follow the card to my import and animating sprites tutorial and you can learn from there the first thing we're going to do is create a new sprite and we're going to name it SPR wall and we're going to come in and all we're going to do is fill it with black which is going to be a simple black wall I am NOT an artist we are going to Center this by going middle Center we're going to exit out of it and create a new object called obj wall and we're going to assign it that sprite we're going to set it to solid we're going to come in to Sarah set her to stall it and add an event of a collision with the wall we don't need to do anything with it that's just so that she'll actually run into the wall it'll look nicer that way now let's load up our room by default the black the background is black if you want to change that you can click on background and change the color here just make sure you're on the instances tab and we are going to drag in this wall we're going to put it here in the corner and by holding down alt I can make another one up here and then I can drag and click and create as many instances of these as I want so all I'm going to do is make a border around the room and I'm going to make two right here and put Sara inside of this room as well so now we have the first room that you can move around it the last thing we need is actually just one more sprite we're going to call this obj or SPR warp we're going to come in here and I'm just going to put some text let's fill it with nice purple text first we'll fill with like a gray color with a gray color we'll come in here and we'll put some text in here that says warp and that's all we really need it's super simple go back to here we'll put middle Center just going to like to Center everything and we'll make an object obj warp we're going to assign it this sprite and in your game you would make it so it's not visible for here though I'm going to keep it visible so that you can actually see it and that you know when you're running into it and such then we're going to add an event we're going to add a collision event with obj Sierra and this collision event is going to say where to put the player but first we're going to add one more event and it's going to be the create event and inside of here we're actually just going to create a couple of variables so I'm going to save our target room target X and target Y and that's all we need these are just local quick variables that only need to be accessed once then we're going to go into the collision event with Sara now the way this works is that when the room is created you were going to say warp object this is where your destination goes to so all way to do is set up the code in here for it to know how to do that so we're going to use the function room go to target room obj Sara dot x equals target X and obj Sara dot y equals target Y so we'll save that and then these will turn blue because they are variables that we are using over here so now what we need to do is go in and make one more room and again let's change the background this way we know it's different let's do like a nice blue background and we're going to make we're going to put in some walls in here so they go back to instances and just so that you know you know it's a different room let's do kind of a weird wall formation okay and we'll have the player come out over here so we're going to take this warp we're going to place it right there we're also going to go into the first room we're going to place the warp right here now this is how this whole thing works there is a thing called creation code for every instance every object in your room you can have the room actually tell it to do something when the room gets created and so what we want to do is double click on our obj warp and that brings up its instance code and we can actually go into creation code here and this is where we alter it so we're going to say because we are right now in room 1 that's the tab we're in so we're going to say target room we're going to assign this variable equal to room 1 and we're going to say target X well for that we need to actually go into room 1 and we need to look and see what x and y coordinates are here so for safety we're going to say X is 380 and Y is 150 so 380 150 so let's save that and run it that's just the very first object war but you'll get the idea here very quickly so we can move around if we hit this warp well she's not persistent let's go into objects there click persistent and run again that can be a problem as well if you forget to do that not clicking persistent means that you won't appear in the next room but if we do this we hit the warp we go into here now this form is going to give us an error because we haven't set up target room variable that's a way to quickly and easily know if it's working correctly if you haven't set it up it's going to throw an error but if we come into room one we double click on this go into creation code or we say target room equals room one target x equals something and target y equals something so let's go and take a look over here and the x and y coordinates if you can't tell are right here these numbers I keep moving so that's what I'm looking at and you want to make sure that you're far enough away that it sarah is not hitting this warp when she comes in if she's hitting that warp when she comes in she will automatically fly back to the other room and it will appear that your warp isn't working properly which is why you always want to have them appear a little ways away or put the warp on a cool-down say like two to three seconds after they hit the warp they can't go back into another warp that would be something a little more advanced that you can do but here we're just going to make sure she's placed far enough away so this looks about 8:35 and for 18 that's what we're going to say 8:35 and for 18 we're going to click run and now we're going to have a game with changing rooms super easy so we hit this warp we're in this room we hit this warp we're in this room one object all you do is alter the creation code it's super simple super easy to setup and it allows you to be really flexible because once you know how to work this you can add a lot more variables in if you want to do now just to show you that this looks a lot better than it actually does we'll take off the visible variable for the warp and then we just hit this and we warp same thing still activates doesn't have to be visible for the players to change rooms so I hope that you found that helpful if there's any tutorials or anything that you'd like me to cover in the future please leave a comment below hit me up on Twitter I am active and always looking for new ideas if you'd also like to vote on what I create next support me on patreon I put out polls on there that you can influence the content that I make as always though have fun making great games and I will talk to you later hey there I've got a patreon if you didn't know if you'd like to support me that would be great up on the screen are the people who are pledging enough to get their name and the credits they are helping fund this YouTube channel which is awesome I just want to give a shout out to them and all that they do to help me do this it's great if you would like to join you can click on the link at the end of the video or in the description below thank [Music]
Info
Channel: Let's Learn This Together
Views: 59,698
Rating: undefined out of 5
Keywords: Game Making, Making Games, Game Maker, Game Maker Studio, Beyond Us Games, Game Maker Tutorial, Game, Maker, Studio, Tutorial, Training, Learn Game Maker Studio, Learn Game Maker, Learn Game Making, GameMaker Studio 2, GMS 2, GMS, YoYo Games, BUG, New Project, Newbie, Beginner, training, room, rooms, change rooms, change room, how to, beginner tutorial, how to change rooms, getting started, misc tutorial, elegant room change, warping, room warping, how to warp, basic, gamemaker 2
Id: PRdMlHVtOFA
Channel Id: undefined
Length: 10min 2sec (602 seconds)
Published: Sun Apr 23 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.