Thank you! I was having a hard time with this LMAO My transition into the house, I have to walk the player up before the blackalpha will go away where I can see, but when I leave the house its normal, any ideas? EDIT: I figure out my issue was my obj player was spawning on the transition zone creating more then one instance of it I believe, either way when I changed the spawn coords the transitions are smooth and fixed
Really helpful tutorial! How I personally handle room transitions is by creating a room transition object when the player colliders with the door and having that object handle all logic and then deleting itself.
I am totally using this codebase when making an rpg. It has all of the basics covered, and organized in a better way. I appreciate GameMaker Studio because it's a middle ground between RPG Maker and games coded from scratch. The scripting is very powerful, but a lot of the basics for 2D games are already built into the editor. At the same time, the limits of the game engine are very few. The only really noticeable downside is that the event system could be improved (mainly not being able to define custom events). Oh well, there are other ways to do the same thing, it just requires a different kind of solution. Honestly, all game engines have their downsides, but GameMaker Studio has good documentation and people like FriendlyCosmonaut are amazing at giving tutorials :)
Loving this series so far! Thank you for all the great explanations! :D I keep having typos and messing stuff up, but when I do find the solution it's just that much more rewarding :P
Thanks a lot. It took me much longer than I expected to finish this video there was a lot of material covered and had to go back few times to figure it out. Not really your fault just me being rather slow learner when it comes to abstract things. I have learnt a lot however and can't wait to get started on your next video soon. Keep them coming :)
Ah, well let me know if there are concepts you struggled with! I'm mildly aware when I'm explaining that I could have spent longer or gone through it differently, but it's hard to know how you guys find it. So if you are having trouble, maybe it is my fault! Always feel free to tell me if you'd have liked something explained more/differently.
No I think I got there in the end just needed to pause few times and rewind. Overall I find your series very organised and much more clearly explained than most I have seen on youtube.
Wow... 12:30 - 18:30 you're going blazing fast. I think that section could benefit by being supplemented by maybe showing a little flowchart like you did with the movement code earlier in the series.
Awesome tutorial, love these and and am enjoying learning gamemaker. @29:40 I was able to also fix this by putting this at the start of my player step event: if (game.transitioning) return; This is neat because it prevents input for a few so the player can't accidentally move back and avoids some code duplication. I also moved the collision layer hiding logic to the game's Room Start event just so I don't have to remember to add this in every instance create. if (layer_exists("Collisions")) layer_set_visible("Collisions", false); if (layer_exists("Transitions")) layer_set_visible("Transitions", false); Hope this helps someone else. 👍
I have a problem! Around 23:00 you typed enum dir { right = 0; up = 90; left = 180; down = 270 } Well, for some reason it is only recognizing "right"! up, left, and down are all white instead of red, and the code won't run. I don't know why it is like that. I did everything exactly like you did! Edit: NEVERMIND I FIGURED IT OUT! I was using a semicolon instead of a comma.
Wonderful! And just to note, not only can you use your mouse to get an idea of the x/y of where your character should spawn you can drag one of those npcs to the position to see how you would basically be standing at that location and note their x/y to put in the warp field.
Does anyone know when in this series she wrote the code on screen at 9:49 ? (the //horizontal and //vertical collision detection) I am having an error on one of those lines because I can't see the full line of code to make sure I match it!
Fantastic tutorial series. Thank you. I had a problem where the player object wouldn't appear at the correct co-ordinates when moving room. Worked out I didn't have my 'game' object set to persistent.
I'm watching your tutorials and I'm having fun learning, but I'm curious. At places like 24:00 you have us set up new variables but you have us set the variables as -1. I'm assuming this is because 1 is true and 0 is false, so -1 wont trigger anything or in data sets like directions where you only have 0-360 degrees, -1 doesnt exsist and will get ignored. Is that why you keep using -1 for values that are going to be replaced based on instances later? Or is there another reason for that?
I'm having a problem similar to gloss_v2 below, where the spawn point isn't getting properly set. Through a little debugging, I can see that the problem is that the player's X and Y are never properly updated - the spawn point is just whatever oPlayer's X and Y were at the time of the room transition instead of targetX and targetY in the oTransition's instance creation code. And the reason for that is that spawnX and spawnY aren't being updated in oGame. I think the issue is in my oPlayer's step event: var _inst = instance_place(x, y, oTransition); if (_inst != noone) { with(oGame) { if(!doTransition) { spawnRoom = _inst.targetRoom; spawnX = _inst.targetX; spawnY = _inst.targetY; doTransition = true; } } } ...well, never mind. I figured out what I did. I'm posting it anyway in case anyone else does the same thing. I plugged in the coordinates just next to the Transition instance I was colliding with instead of the Transition instance I'd be arriving at. For example, at the exterior door to my farm, I set targetX and targetY to coordinates just outside the farm's exterior door, when I should have set coordinates that are just INSIDE the interior door in the interior room. Ugh, I shouldn't code when I'm tired...
Sorry for the late reply (I'm still on holidays) - though I'm happy to see you've solved it! Thank you for posting the solution, I'm sure it will help others.
I got an issue in fading part. Idk why it works like that: 1.When stepped on transition obj Fading beggins 2. When it is >=1 then changes room 3. And there is an issue that fade out is instantly. Idk why GMS2 forgots about what it done to black_alpha an sets it to default from number from create
Hey, not sure if you or anyone else checks this, but for whatever reason the black box thats supposed to appear over the entire gui only does a partial block, even though I have the viewport properties, camera properties, etc all in sync. I fixed it by using display_set_size(1600, 1440);, but I'm still wondering why the issue was there in the first place...
When I try to make a transition from the farm to the farm_house mmy game freezes a bit then the player appears in the top left corner. Somehow the transition to this room doesnt work but when I make the transition into the forest it works without a problem. Do you know why this may occur? It may be from the dimensions of the room?
If you click on your room and then check you Properties box in the bottom left corner, is your Viewports and Cameras settings ObjectFollowing attached to your player object?
I'm new at programming so I'm not sure how this is happening, but the transition is only working correctly once, from the farm to the house, and all other transitions are putting the player on the (0,0) coordinates, and from what else I could find out, changing the player layer. as in, the player starts the game in the correct layer, but once it does the transition once, and then goes back outside, the player can walk on top of the roof but still collide with the stuff. I'm not sure why it's doing this, and I'm sure I probably misspelled something somewhere, but I can't figure it out where.... update: I remade the code this time trying to pay even more attention to your video and I think I managed to fix it, I still don't know how ...
the obj_player does not appear in the coordinates that I indicate and I have checked the Code and I do not have any error, it appears in other coordinates not even close to those that I have placed.
I've watched the video twice now but for some reason the black fade rectangle only forms over the top left portion of the screen, I can't figure out why
So the rectangle is drawn in the "Draw GUI" event of the game object. The command is draw_rectangle_color and the first four parameters it asks for are x1, y1, x2, y2. X1 and Y1 are the origin at the top left of the screen and they should be set to 0, 0 because GMS2 draws the room from the top left to bottom right. X2 and y2 are the finishing co-ordinates for the rectangle and the value we put in there is guiWidth and guiHeight which are variables we have set ourselves in the create event of the game object. The variables are guiWidth = display_get_gui_width(); guiHeight = display_get_gui_height(); The "display_get_gui_width/height" function returns the value of the amount of pixels in the display. So you are telling it to draw from the origin at the top left, all the way to the number of pixels that exist in the display. Hope this helps and apologies if I've got anything wrong, i'm pretty new to this myself.
@@panzeros5714 im getting this same problem, its drawing over most of the screen but the fade is being cut off on the bottom and right. ive checked my code a dozen times, its gotta be returning wrong values or something. im on two screens, my laptop screen, and a high-resolution monitor, could it be the difference in resolution? that really shouldn't be it but ive been trying to fix this for over an hour
I dont Know whats wrong, i wrote the code out with the room_goto (var) and it worked. I then added the rest of the code in the vid and now my player would collide with the door. it just fases through... any ideas? To be honest in the one just before this i couldent get the 'with()' command to work either... is it just my version of GMS?
So, I'm at 21:28 and I've hit a problem. When I transition rooms I go to the next room. However, I instead of spawning next to the transition object, I spawn directly at the top. I assume I'm spawning at 0,0. I'm not sure why. Its also a problem because I have collision boxes set up around the edge of my map, so I'm spawning inside a collision box when I transition. Otherwise everything about the transition including the fading is working. I'm gonna re watch the video to make sure I did everything right, but any help would be loved. If and when I figure out whats gone wrong, I'll post it in a reply to this comment so anyone having similar issues can get a leg up.
@@GarettMitchell have you been working on this video series since may third or on this problem since then? Its gotta be something to do with the coridinates not connecting. Because everything else works perfect.
@@GarettMitchell Ok, so I figured out what we did wrong. or at least what I did wrong. at 19:44 is about when she starts explaining it but for a very brief explanation, you need to set the transition coordinats (TargetX and Target Y) in the transition instances themselves and do it for where you want your sprite to end up in the next room. So for instance, you need to have a line in the instance creation code of TargetX = and then set the X postion in the house where you want the sprite to appear.
I had a problem that the game was not transitioning when I switched to the fading. deleting the game object in room 0 and re adding it fixed it. Strange but that's all it took.
what exactly do I have to consider if I want to program this room transition with an following object like a NPC? Thanks in advance and merry christmas :D
7 лет назад+1
Thank you so much! But I have a problem. Everthing worked fine until I move the code below to "object game". when I start the game my char facing north and move animation is on all the time.without even pressing any movement key:( and facing only changing when a room transition done. with(oplayer) { switch (facing) { case dir.left: yframe = 9; break; case dir.right: yframe = 11; break; case dir.up : yframe = 8; break; case dir.down: yframe = 10; break; case -1 : xframe = 0; break; } }
7 лет назад
seems like I cut the code. but I had to copy! . it sounds bit weird to have same code twice in 2 different objects.animation problem solved but facing after transitions are not right. bit confused:)
Sorry, do you mean you moved this bit of code, which is how the player sets its sprite/direction, entirely out of the player and moved it to the game object?
7 лет назад
Yea. at first I cut the code out of objectplayer and ruined all facing animation stuff:) then fixed it by copying.
I'm struggling with the transitions and different camera sizes. I've noticed that my draw GUI events never actually cover my whole display when I run the game, which messes with the transitions and other screen related stuff. I had the same issue following Shaun Spalding's tutorials. I know how to fix it, but I'd like to understand why it happens. Any suggestions? (I'm literally copying and pasting your code and settings)
I'm having some trouble after switching from the "room_goto" method to the "spawnRoom" method where the character no longer transitions when touching the transition object. I've checked the debug and it says transition = 1 and the spawnRoom changed each time, so I'm not sure what's wrong. I can upload my project if need be.
Hey - I've had a few people had this problem before. Interestingly, every single time it's been an issue with inconsistent variable names, ie. calling spawnRoom Spawnroom, spawnx and spawnX, etc. So I'd suggest having a very careful look over your code for these, they can be hard to spot! Let me know if you still can't find the issue.
@@FriendlyCosmonaut Still same problem here even though I'm fairly an experienced programmer, but never made a game with Gamemaker Studio 2 before. Please let me know if you or someone has a fix for this.
@@FriendlyCosmonaut I debugged and blackAlpha never gets updated to more than 0.10, so that's why the transition didn't work, because the if statement didnt' meet the condition of blackAlpha >= 1, so room_goto(spawnRoom) wasn't used.
I had a problem where my player was changing rooms fine, but the black transitions were not showing. I eventually solved it by removing the code " room_goto(inst.targetRoom); " from the player objects step event Perhaps this will help someone else with the same problem.
Couldn't you leave off draw_set_alpha(1) when handling the fade? Every frame, the alpha is being increased until it reaches one. no reason to set it to one at the end of the script every time...
whenever I go between the rooms, im seeing the background of the new room, but my player is not showing up in the new room. Any idea why that would be happening?
That sounds like the room transition is happening correctly, but the respawning of the player isn't. I'd check all the variables and code involved in respawning the player (usually things like this can be as simple as a spelling/grammar mistake). If you can't find it, feel free to send me your project file (file -> export project) and send it to friendlycosmonaut@gmail.com
I have faced the same problem. Maybe someone will find my suggestions useful. 1. Make sure you have a background set in your house room, (just a flat black color for example, i personally created a filled with black "background" layer to solve this problem ). 2. Make sure you have house's entrance trigger TargetX and TargetY set properly (choose the coordinates inside of your house room, where you want your player to spawn). 3. Make sure you have made a camera persistent.
I'm using the tileset you provided to make the room interior, and I'm trying to use the technique you showed us for animating tiles in a tileset. But I'm having an issue trying to animate the clock and the stove. When I go to the Tile Animation area for the tileset, I can only set one FPS for the entire set. I'd like the clock to move at 1 FPS but the stove to move at 5 or 6. How do I accomplish that?
Yeah the FPS you set is shared by all the tiles. A way around this is to set it at the "fastest" FPS you need, and then for the slower ones, just fill up the frames with the same picture to make it seem like the animation is slower.
Lovely tutorials! My GUI dimensions are coming up smaller than my viewport and I can't figure out why. I've followed along super closely. Has anyone else had this issue, or anyone know what I could try? I'm really scratching my head on this one!
@@clarisse9170 Funny enough, I just found that solution a couple days ago! It comes up again in a view videos when we do the day/night cycle and the lighting. I actually put it on the game object Create event. Something seems fishy about it, but it does appear to work fine. Must have something to do with different computers/monitors and screen resolutions? :shrug:
@@rreeppeeaatteerr really helped me out here, thank you so much! working on a non-pixel art game so my dimensions for these videos are all sorts of different, lol
Hi, great video. My idea about spawn is using another object as spawn point with assigned variables facing and spawnName, then you need only store in persistent game instance 'targetSpawnName' because all others value are assigned on spawn object and object position you can use x,y for player spawn position. // Room start event //obj_player.x = spawnX; //obj_player.y = spawnY; var i; for (i = 0; i < instance_number(obj_spawn); i += 1) { var spawn = instance_find(obj_spawn,i); if (spawn.spawnName == game.targetSpawnName) { obj_player.x = spawn.x; obj_player.y = spawn.y; obj_player.facing = spawn.facingDir; exit; } } Great job with GM2 tutorials btw. ;)
For some reason blackAlpha is not increasing when I touch obj_transition. I've checked over all the variables and they're consistent. I'm completely stumped.
I am having an issue coding the transition for entering into the house. I have checked over my code and re-watched the video, with nothing seeming amiss. The transition to the forest and back to the farm works fine. However, the one to the house is having issues. I get a fatal error in the Room Start event for the game object. It lists: "Unable to find any instance for object index '1' name 'obj_player' at gml_Object_game_Other_4 (line 4) - obj_player.y = spawnY" I have looked over that section of the code and there seems to be no irregularity. Could anyone give me any advice regarding the matter? I cannot fathom why the code would work for the transition to the forest but not the house.
Hey. It means your character object gets deleted before it can be read - there is a simple fix for it. 1. Go to Objects > Characters > obj_player (or wherever your obj_player is located at) 2. Double-click it 3. Below "Collision Mask", there are four tickboxes 4. Tick Persistent Have fun coding!
@@Karazaro That worked! Thank you very much, I have thoroughly been enjoying the coding. But I have another issue as well. When I enter the farmhouse, (either from upstairs or downstairs), there remains a still image behind it. When I enter the farmhouse from the farm, it shows a background of the rm_forest for some reason behind the farmhouse room itself. When I enter it from the upstairs, it shows the last image displayed in rm_farmhouse_upstairs behind the farmhouse (i.e., a still image of obj_player colliding with the stair transition area). Any idea what might be causing it?
@@haydencarlson2746 At first glance, it looks like your camera object is not moving properly. Try to look up the episode where she created room 0 first and how she made objects change rooms from it! :)
What if you have both a run and walk animation? I coded it like this if (moveX 2 ) y_frame = 5; //RIGHT RUN else if (moveX > 0 ) y_frame = 1; //RIGHT else if (moveY 2 ) y_frame = 4; //Down RUN else if (moveY > 0 ) y_frame = 0; //Down else x_frame = 0; //STOPED
Any reason not to put the switch(facing) statement in begin step or regular step before facing gets set? Then its all contained in the player object and you don't need it in your draw event too.
Would there be any reason why the transitions would take a bit of time before actually happening? It seems that the first transition thats made happens instantly but after that intial one all other are taking some time to happen and the chacter can still move before the room is changed.
Hmm that's a strange one. That shouldn't be happening. One thing that comes to mind is that you might have ticked rooms as persistent? This would mean that more and more memory is being consumed, causing the game to load slower.
I have a small problem... I used the 8 directional movement code from another video of yours, so I dont know how to fix the facing problem. If anyone can help, I'd be really thankful
For some reason my rectangle won't cover the whole screen, my variables seem to be exactly as what FriendlyCosmonaut has: obj_game:events:create: guiWidth = display_get_gui_width(); guiHeight = display_get_gui_height(); obj_game:events:draw gui: ... draw_rectangle_color(0, 0, guiWidth, guiHeight, c_black, ... ...
Amazing tutorials! One problem i seem to be having is that dotransition is not registering as true (checked through the debug console) even though inst.targetroom changes appropriatly. I've checked for spelling and my code seems to be spot on with yours so I am really just at a loss. Any help would be appreciated and thanks so much for your hard work!
Here's a huge newbie question for someone: Can you remind me why we are setting so many variables to -1 as their initial value? And how does this differ from setting them to, say, 0 as an initial value? I'm still not thinking like a coder yet...
Great question! I know things like this seem pretty arbitrary - and actually, they are. A lot of the time stuff in programming is done because of convention. And by convention, variables are often initialised as being equal to 0 or -1 or undefined. Those values are sort of supposed to just indicate that the variable hasn't really sorted itself out yet. But there are some quirks in GameMaker where numbers >= 0 are actually used as indexes for things like arrays and data structures (if you run the game in debug mode and have a look at what "value" your data structures are, you'll see a number, not a bunch of numbers like you may be expecting from an ID). So initialising a data structure as being equal to 0 can cause some trouble later on, because if you check for example if that data structure exists, if you've set it to 0, it might think that it actually does (because 0 is a valid value for a data structure in GameMaker). So that's why setting them to -1 can be a bit "safer". Hope that makes some sense!
ok so i managed to get this working fine however i have the same building in multiple rooms and cant figure out how to get the player to go back to the room it came from because i can only put 1 target room. Any ideas?
So you're saying you have the same instance of the transition object in each room? Remove it and place a new one, so that you can then change the location in that instance. Remember you're placing the code in the individual instance, not the main object. You should be clicking Creation Code, not Edit Object.
Yeah i am putting it in the creation code. I'll rephrase it. The building is in village 1. Village 1's target is to go inside the building. Inside the building, the target is to go outside to village 1. However, this same building is in village 2. Village 2's target is to go in the building but because its the same room inside, the transition object still has village 1's target. I need a way to go back to the village it came from. Sorry if its a bit of a bad explanation.
@@rhysh993 ah I get you. So you're treating it as the same building but want it to go back onto to where you came. So I can think of two solutions. 1) you make a seperate house for the second place to go to, if you're wanting to pretend they are different this is probably best. 2) you could create a variable that is changed by the transition squares going to the house. Then the square in the house has an if function that says if variable = A it runs as going to village A, and if variable = B it goes to village B. Hmm also, if you're acting like one is a different route to the same exact house, then you could just have a different door, like a trapdoor, that one village is linked to
Those are pretty good ideas although creating separate houses may be an issue because im gonna need more than two (as i need them for more villages later on) so although that solution would work and i can easily do it, it will just leave me with lots of rooms, taking up space. The second option, well I'm relatively new to game maker so i honestly have no idea as to how i would go about making the variables do as intended (i tried before and it was just not working). So if you had any ideas as to how to go about doing it, it would really be appreciated As for the third option, there's only one door to the building so making another door is not an option
@@rhysh993 I'm reaaaaaaaaaaaally not an expert, I'm just doing the tutorials like you. And I can't do this on mine coz I'm scared this will break it, but have a go with my solution below, and debug it for practise lol But if you take this bit from the player step screen var inst = instance_place(x,y,obj_transitions); if(inst != noone and facing == inst.playerFacingBefore) { with(game){ if(!dotransition){ spawnRoom =inst.targetRoom; spawnX = inst.targetX; spawnY = inst.targetY; spawnPlayerFacing = inst.playerFacingAfter; dotransition = true; } } } This is where the transition happens. So. In the player create (edit: maybe this needs to be in the game object? Try player first) make a new variable, say last_room = -1; then in the creator for each instance of the transitions to the house, you want them to have a variable. room_from = villageA; for example. Then you want to add a section into the player transition section above that changes the player last_room variable to the room from so under spawnRoom = inst.targetroom; write last_room = inst.room_from; This will change the variable in the player to the room that it's just come from OK, so we can see in the main player transition that we need the inst.targetRoom, the targetX and targetY. So in the transition that you need inside the house to go to multiple places, go to the creation code. It should be targetRoom = rm_farm; targetX = 1006; targetY = 696; playerFacingAfter = dir.up; playerFacingBefore = dir.up; Well now all you need to do is say "If last_room = villageA then do all this for villageA, if last_room is village B, then do all this for village B. so for example if my two villages are rm_farm and rm_farmB if last_room = villageA { targetRoom = rm_farm; targetX = 1006; targetY = 696; playerFacingAfter = dir.up; playerFacingBefore = dir.up; } else if last_room = villageB { targetRoom = rm_farmB; targetX = 1006; targetY = 696; playerFacingAfter = dir.up; playerFacingBefore = dir.up; } So if we think it through, as you transition INTO the house, you change a variable to say "This is the last room I was in" (and you won't have this changed by different rooms in your house, it will just stay the same). Then when you leave you're saying "If the last room I was in was this, send meto this place, if it was this other one, send me there." Hope that helps, let me know, and sorry if it doesn't lol I'm really not great at this. As an aside, I don't think your game would get too big from just having different houses. dunno if this is possible, but you could maybe have an object that's a house, and then in each house room, you place that, and it's basically a premade house, and then you just add extras, or changes on top of it. The problem will be that if you do as planned, each house won't just look the same, it will BE the same, so at that point, what's the point in having them all?
Thanks for the video. Still so helpful even after so many years) Can somebody please help me to grasp the logic of Room Start Event - the player's facing is set in Room Start Event according to the obj_transition instance's vale, but shouldn't it be then updating by the player's step event since it should be working every frame after the room start and in that event the player's facing should be reset to -1 since moveX and moveY equal 0 so the facing should be changed again after Room Start Event. I don't get why it isn't happening :'((
was stuck with the fast part between 'game' , 'obj_player' and 'obj_transition' before realising my brackets should have been closed off before an 'else' DOH. this is what i get for watching this in a tiny popout window
my room change isnt working... >.> i dont really know coding all that well but im thinking its the " inst " . those are the only 3times ive used it so i dont see how it would work anyway... any help would be appreciated :) var inst (instance_place(x,y, ObjTransition)); if (inst != noone) room_goto(inst.TargetRoom);
The room transitions worked wonderfully, but once I added the fade effect, it stopped working! If anyone has had this problem and knows how to solve it, that'd be nice to hear. Thanks!
I decided not to have the fade effect, and got rid of it, but for some reason, my character is invisible when I enter the next room. I can tell he's in the room, because the camera moves, and I can move back into the other room. I tried making another room to see if he'd be invisible if I move into that one. He was. However, if I move back into the starting room, he is visible again.
@@nickspencer2207 try removing the draw event if you have any. Or, you can always to drawSelf() or something like that, cant really remember but make sure you either do one of those
Have you ever considered turning this into a Udemy course? It's probably at the same level as most of the one's I've taken - maybe more so because I'm learning a lot! Thank you!
Is it alright to give you suggestions of what tutorials to do next? If so, would you be up for making a tutorial to a drawing program, something Mario Paint-esque? Things like the actual drawing, erasing, saving the images, etc. I noticed that tutorials for these kinds of games are very scarce.
I really like your series, but in a bunch of videos and this one specifically a lot of the code doesn't work anymore. It would be amazing seeing you do a similair series, but up to date!
thank you so much for these videos! they've been a great help! Though I ran into a problem with my transitions as it seems that when I collide with a transition object, it works the first time but if I repeat the collision with the transition object it will place me in the room I am currently in. It'll do this as many time as there are rooms in between my current room and the roomTarget (ex: I have 5 rooms set up, current room is 2nd in the list and roomTarget is 3rd. It'll reload me back in the 2nd room every time I hit the transition object after the first time five times, as if going through all my rooms before landing on the right room) I'm fairly new to programming and GML in general so I'm not too sure what I did wrong or how to fix this issue? If anyone can offer some advice that would be a real help, thank you! (also I do have a room0 set up with my meta objects with room_goto_next(); being the first thing in my create event) EDIT: after a lot of head scratching and looking over my code, it wasn't a problem with the code actually lol all my rooms were marked "persistent" when they shouldn't have been WHOOPS
I made a major boo boo! I made a bunch of rooms right away and viewed them..this erased everything all folders and instances Now rm_1 and Background are blank! ;( Idk if I lost it all? I never saved. I shut the game down, I deleted the rooms. I played the game all blank! Do I need to re-do days of work now? Redo all my layers and place things back in or what! Be extremely careful when making new rooms people!!
Little Question... hope someone can help me with that... after implementing the switch for facing in the player object my character doesnt animate correctly... up and down works fine but left to right doesnt work anymore, she's still moving but wont show the animation for left/right movement... here's my code for that: Oh and btw love your Tutorials very much
I had the problem that the teleport did not teleport me into the house but to the teleport point outside the house. Then I realized that the teleporter from outside has teleported right into the teleporter inside. And the inside teleporter kicks me back outside. Omfg 2h of Brainfuck. Hate my life.
to anyone getting stuck in the transitions, I deleted my target room and recreated it and suddenly it worked :) my advise is try with one room first before creating your whole village just in case you run into an issue
Hello, can you give me a hand please :D I´m having problem with mooving to 2nd room after finishing fade effect. In player/step/objects when I change var inst = instance_place (x, y, obj_transition); if (inst != noone) { room_goto(inst.targetRoom); } to var inst = instance_place (x, y, obj_transition); if (inst != noone) { with (game) { spawnRoom = inst.targetRoom; doTransition = true; } } is the point when I can´t move to another room. Im not getting any errors I can walk trough transition object how long I want. I followed everything in the video 3times :D and still not working
Well you also need the code for actually doing the transition in the *game* object. Everything is set up, but the "doTransition" code might have a problem in it, so have a look at that - or post it here so I can have a look :)
project file: goo.gl/aa9hoH I guess it will be easier than from screenshots. I did everything as you showed until 22:00. If you figure out, please let me know what I did wrong because I spent hours and got nothing :D //doTransition is set to false in obj_game/create event
Oh goodness sorry for the delay - I've found the bug! I've stumbled across this one a couple times before, you'll probably laugh when you read this: So the problem is that the game object was not "visible". This means that its draw events will NOT be run - which of course, means the room transition code wasn't running. So just tick "visible" in the object editor and everything will work fine :)
Haha, no worries I´ve been working on sprites since then :D Damn it :D I´ve been playing with visibility on obj_transition, but not on the actual game objective :D Thank you so much for problem solving :)
I am having the same problem, but not even checking the object to visible solves it :/ Remade the game object copying the code exactly as you did, but nothing works. Help Cosmonaut!
FC your tutorials on textboxes and room transitions are amazing and have really helped me, but I've hit a brick wall in my project at changing the direction the player faces after room transitions :( Long story short I set up my animations in the player object's step event and in the creation event I set his initial direction to down, but now every time I change rooms and my player object is created it runs that little bit of code and he looks down, but I can't get rid of it because I need to tell the game where to face my player when I start the game D: If anyone can help me I would be really grateful.
Hmm that's a little odd - that create event for the player should be running BEFORE we change its direction. Unfortunately this one's a bit hard to guess, so I may have to see your code to know what's going on. Could you send me some screenshots of the code pertaining to changing the player's direction, or just the whole project file, to friendlycosmonaut@gmail.com?
Thank you so much for offering to help me but I ended up figuring it out after some messing around! I'll write out my solution here just in case anyone has the same problem I did: I basically just ticked the "persistent" box on my player object so that the initial direction is set when he's created (down) but is then changed to either left, right, up or down depending on which key is pressed, so when I transition through rooms that variable remains the same so if I walk off screen to the right I appear FACING right when I enter the next screen. I realize that I'm a bit limited in that I can't make my character face 90 degrees to the side after a room transition but that doesn't really affect my current project too much. Anyways thank you so much for these awesome tutorials FC, you're awesome!
look up the browser version of Photoshop and just put all the images into one image. Make sure the background stays transparent and you save it as the right file. It takes a bit of fiddling afterwords to realign all the tiles if you already have some made, but hey it's free!
hmmmmm i've been following along, but i didn't move everything to a separate "game" object because i didn't want transitions, so i kept everything in the player object. so in the Room Start event i've got "if (spawnroom == -1) exit; playerobject.x = inst.targetX; playerobject.y = inst.targetY;" which seems to work, but when i exit the room to come back to the previous one, it still spawns me in the original spawn point (ie not the inst.targetX/Y). any ideas?
2:20 GMS2 No longer loads the first room in your list, you have to set the start room by clicking the little house icon
Thank you! I was having a hard time with this LMAO My transition into the house, I have to walk the player up before the blackalpha will go away where I can see, but when I leave the house its normal, any ideas?
EDIT: I figure out my issue was my obj player was spawning on the transition zone creating more then one instance of it I believe, either way when I changed the spawn coords the transitions are smooth and fixed
int he "room order" underneath "favorites", the first room int he list is the one that gets that little house icon
Really helpful tutorial! How I personally handle room transitions is by creating a room transition object when the player colliders with the door and having that object handle all logic and then deleting itself.
Ahh, yes, this would be good too!
I am totally using this codebase when making an rpg. It has all of the basics covered, and organized in a better way. I appreciate GameMaker Studio because it's a middle ground between RPG Maker and games coded from scratch. The scripting is very powerful, but a lot of the basics for 2D games are already built into the editor. At the same time, the limits of the game engine are very few.
The only really noticeable downside is that the event system could be improved (mainly not being able to define custom events). Oh well, there are other ways to do the same thing, it just requires a different kind of solution. Honestly, all game engines have their downsides, but GameMaker Studio has good documentation and people like FriendlyCosmonaut are amazing at giving tutorials :)
Loving this series so far! Thank you for all the great explanations! :D
I keep having typos and messing stuff up, but when I do find the solution it's just that much more rewarding :P
I can't tell you how excited I get when I see one of these pop up in my feed. Can't wait for the next one.
Thanks a lot. It took me much longer than I expected to finish this video there was a lot of material covered and had to go back few times to figure it out. Not really your fault just me being rather slow learner when it comes to abstract things.
I have learnt a lot however and can't wait to get started on your next video soon.
Keep them coming :)
Ah, well let me know if there are concepts you struggled with! I'm mildly aware when I'm explaining that I could have spent longer or gone through it differently, but it's hard to know how you guys find it. So if you are having trouble, maybe it is my fault! Always feel free to tell me if you'd have liked something explained more/differently.
No I think I got there in the end just needed to pause few times and rewind. Overall I find your series very organised and much more clearly explained than most I have seen on youtube.
Wow... 12:30 - 18:30 you're going blazing fast. I think that section could benefit by being supplemented by maybe showing a little flowchart like you did with the movement code earlier in the series.
Awesome tutorial, love these and and am enjoying learning gamemaker. @29:40 I was able to also fix this by putting this at the start of my player step event:
if (game.transitioning) return;
This is neat because it prevents input for a few so the player can't accidentally move back and avoids some code duplication. I also moved the collision layer hiding logic to the game's Room Start event just so I don't have to remember to add this in every instance create.
if (layer_exists("Collisions")) layer_set_visible("Collisions", false);
if (layer_exists("Transitions")) layer_set_visible("Transitions", false);
Hope this helps someone else. 👍
I have a problem! Around 23:00 you typed enum dir { right = 0; up = 90; left = 180; down = 270 } Well, for some reason it is only recognizing "right"! up, left, and down are all white instead of red, and the code won't run. I don't know why it is like that. I did everything exactly like you did!
Edit: NEVERMIND I FIGURED IT OUT! I was using a semicolon instead of a comma.
Wonderful!
And just to note, not only can you use your mouse to get an idea of the x/y of where your character should spawn you can drag one of those npcs to the position to see how you would basically be standing at that location and note their x/y to put in the warp field.
Yes, good tip!
Does anyone know when in this series she wrote the code on screen at 9:49 ? (the //horizontal and //vertical collision detection) I am having an error on one of those lines because I can't see the full line of code to make sure I match it!
Hi! that would be in the "movement and collisions" video, the second one in this series i do believe!
im having trouble there too. her code is different than the one she had us write in video 2!
Your tutorials are amazing! Thanks for spreading that knowledge around!
Fantastic tutorial series. Thank you. I had a problem where the player object wouldn't appear at the correct co-ordinates when moving room. Worked out I didn't have my 'game' object set to persistent.
Thank you!..
I had the same problem and found that in my player obj the persistence was not checked, I checked it and it works now.
If I could explain to you how long I've been digging through comments looking for a solution...You're a legend, John. Truly.
hi! at 4:26 how did you specifically cut that part of the tile ?
The sheet by itself exists independently of the bed sprite, it's towards the bottom of the sprite sheet
I'm watching your tutorials and I'm having fun learning, but I'm curious. At places like 24:00 you have us set up new variables but you have us set the variables as -1. I'm assuming this is because 1 is true and 0 is false, so -1 wont trigger anything or in data sets like directions where you only have 0-360 degrees, -1 doesnt exsist and will get ignored. Is that why you keep using -1 for values that are going to be replaced based on instances later? Or is there another reason for that?
I'm having a problem similar to gloss_v2 below, where the spawn point isn't getting properly set. Through a little debugging, I can see that the problem is that the player's X and Y are never properly updated - the spawn point is just whatever oPlayer's X and Y were at the time of the room transition instead of targetX and targetY in the oTransition's instance creation code. And the reason for that is that spawnX and spawnY aren't being updated in oGame. I think the issue is in my oPlayer's step event:
var _inst = instance_place(x, y, oTransition);
if (_inst != noone)
{
with(oGame)
{
if(!doTransition)
{
spawnRoom = _inst.targetRoom;
spawnX = _inst.targetX;
spawnY = _inst.targetY;
doTransition = true;
}
}
}
...well, never mind. I figured out what I did. I'm posting it anyway in case anyone else does the same thing. I plugged in the coordinates just next to the Transition instance I was colliding with instead of the Transition instance I'd be arriving at. For example, at the exterior door to my farm, I set targetX and targetY to coordinates just outside the farm's exterior door, when I should have set coordinates that are just INSIDE the interior door in the interior room. Ugh, I shouldn't code when I'm tired...
Sorry for the late reply (I'm still on holidays) - though I'm happy to see you've solved it! Thank you for posting the solution, I'm sure it will help others.
I got an issue in fading part. Idk why it works like that:
1.When stepped on transition obj Fading beggins
2. When it is >=1 then changes room
3. And there is an issue that fade out is instantly.
Idk why GMS2 forgots about what it done to black_alpha an sets it to default from number from create
Hey, not sure if you or anyone else checks this, but for whatever reason the black box thats supposed to appear over the entire gui only does a partial block, even though I have the viewport properties, camera properties, etc all in sync. I fixed it by using display_set_size(1600, 1440);, but I'm still wondering why the issue was there in the first place...
When I try to make a transition from the farm to the farm_house mmy game freezes a bit then the player appears in the top left corner. Somehow the transition to this room doesnt work but when I make the transition into the forest it works without a problem. Do you know why this may occur? It may be from the dimensions of the room?
If you click on your room and then check you Properties box in the bottom left corner, is your Viewports and Cameras settings ObjectFollowing attached to your player object?
I'm new at programming so I'm not sure how this is happening, but the transition is only working correctly once, from the farm to the house, and all other transitions are putting the player on the (0,0) coordinates, and from what else I could find out, changing the player layer. as in, the player starts the game in the correct layer, but once it does the transition once, and then goes back outside, the player can walk on top of the roof but still collide with the stuff. I'm not sure why it's doing this, and I'm sure I probably misspelled something somewhere, but I can't figure it out where....
update: I remade the code this time trying to pay even more attention to your video and I think I managed to fix it, I still don't know how ...
the obj_player does not appear in the coordinates that I indicate and I have checked the Code and I do not have any error, it appears in other coordinates not even close to those that I have placed.
I swear I spend most of my time figuring out what I did wrong when all it was, was an "x" where a "y" should be, took me 20 minutes to find it.
I gave up last night because of the same thing in the Room Start! lol it's nice to figure it out what went wrong on your own though
I've watched the video twice now but for some reason the black fade rectangle only forms over the top left portion of the screen, I can't figure out why
So the rectangle is drawn in the "Draw GUI" event of the game object. The command is draw_rectangle_color and the first four parameters it asks for are x1, y1, x2, y2. X1 and Y1 are the origin at the top left of the screen and they should be set to 0, 0 because GMS2 draws the room from the top left to bottom right.
X2 and y2 are the finishing co-ordinates for the rectangle and the value we put in there is guiWidth and guiHeight which are variables we have set ourselves in the create event of the game object. The variables are guiWidth = display_get_gui_width(); guiHeight = display_get_gui_height(); The "display_get_gui_width/height" function returns the value of the amount of pixels in the display. So you are telling it to draw from the origin at the top left, all the way to the number of pixels that exist in the display.
Hope this helps and apologies if I've got anything wrong, i'm pretty new to this myself.
@@panzeros5714 im getting this same problem, its drawing over most of the screen but the fade is being cut off on the bottom and right. ive checked my code a dozen times, its gotta be returning wrong values or something. im on two screens, my laptop screen, and a high-resolution monitor, could it be the difference in resolution? that really shouldn't be it but ive been trying to fix this for over an hour
I'm not sure if this was adressed in a video but why use the =-1 when setting up a reference? Thanks!
I dont Know whats wrong, i wrote the code out with the room_goto (var) and it worked. I then added the rest of the code in the vid and now my player would collide with the door. it just fases through... any ideas? To be honest in the one just before this i couldent get the 'with()' command to work either... is it just my version of GMS?
Great tutorials but I can't get my transitions to work even though my code is exactly the same as yours. And no typos have been made. :(
Berk Unver Still nothing :(
That happened to me.. I just retyped the code and it started working for me
@@athemulu lol
If you have physics enabled make sure to use phy_position_x & phy_position_y for the player object
So, I'm at 21:28 and I've hit a problem. When I transition rooms I go to the next room. However, I instead of spawning next to the transition object, I spawn directly at the top. I assume I'm spawning at 0,0. I'm not sure why. Its also a problem because I have collision boxes set up around the edge of my map, so I'm spawning inside a collision box when I transition. Otherwise everything about the transition including the fading is working. I'm gonna re watch the video to make sure I did everything right, but any help would be loved. If and when I figure out whats gone wrong, I'll post it in a reply to this comment so anyone having similar issues can get a leg up.
I've been having the same problem in my code. I have been working on this sense May 3rd. It's super annoying.
@@GarettMitchell have you been working on this video series since may third or on this problem since then? Its gotta be something to do with the coridinates not connecting. Because everything else works perfect.
@@GusOfTheDorks I've been working on the problem sense may third.
@@GarettMitchell oh wow. Now I really want to figure this out. Id hate to leave a gellow gsme maker hanging. Ill let you know when I find anything.
@@GarettMitchell Ok, so I figured out what we did wrong. or at least what I did wrong. at 19:44 is about when she starts explaining it but for a very brief explanation, you need to set the transition coordinats (TargetX and Target Y) in the transition instances themselves and do it for where you want your sprite to end up in the next room. So for instance, you need to have a line in the instance creation code of TargetX = and then set the X postion in the house where you want the sprite to appear.
What is the importance of setting a variable to 0 versus -1? If these variables are going to be changing anyway, why not set them all to 0?
I had a problem that the game was not transitioning when I switched to the fading.
deleting the game object in room 0 and re adding it fixed it. Strange but that's all it took.
thanks.....thanks....sooomuch!!!!!
didn't work on me, scren goes black, black never fade aways, it just stay as it is.
what exactly do I have to consider if I want to program this room transition with an following object like a NPC? Thanks in advance and merry christmas :D
Thank you so much! But I have a problem.
Everthing worked fine until I move the code below to "object game". when I start the game my char facing north and move animation is on all the time.without even pressing any movement key:( and facing only changing when a room transition done.
with(oplayer)
{
switch (facing)
{
case dir.left: yframe = 9; break;
case dir.right: yframe = 11; break;
case dir.up : yframe = 8; break;
case dir.down: yframe = 10; break;
case -1 : xframe = 0; break;
}
}
seems like I cut the code. but I had to copy! . it sounds bit weird to have same code twice in 2 different objects.animation problem solved but facing after transitions are not right. bit confused:)
Sorry, do you mean you moved this bit of code, which is how the player sets its sprite/direction, entirely out of the player and moved it to the game object?
Yea. at first I cut the code out of objectplayer and ruined all facing animation stuff:) then fixed it by copying.
I'm struggling with the transitions and different camera sizes. I've noticed that my draw GUI events never actually cover my whole display when I run the game, which messes with the transitions and other screen related stuff. I had the same issue following Shaun Spalding's tutorials. I know how to fix it, but I'd like to understand why it happens. Any suggestions? (I'm literally copying and pasting your code and settings)
Exactly my problem. When I worked on this on a monitor it wasn't doing it though, so maybe it's the type of computer?
A lot of stuff going on in this one, gonna have to watch it through a couple of times to make it stick :) Looking forward to the next part!
Yeah I'm worried it got a bit convoluted at times :S!
I'm having some trouble after switching from the "room_goto" method to the "spawnRoom" method where the character no longer transitions when touching the transition object. I've checked the debug and it says transition = 1 and the spawnRoom changed each time, so I'm not sure what's wrong. I can upload my project if need be.
Hey - I've had a few people had this problem before. Interestingly, every single time it's been an issue with inconsistent variable names, ie. calling spawnRoom Spawnroom, spawnx and spawnX, etc. So I'd suggest having a very careful look over your code for these, they can be hard to spot! Let me know if you still can't find the issue.
@@FriendlyCosmonaut Still cant sort the issue out :( All of the variables are correctly named
@@masquerade0133 Same :(((
@@FriendlyCosmonaut Still same problem here even though I'm fairly an experienced programmer, but never made a game with Gamemaker Studio 2 before. Please let me know if you or someone has a fix for this.
@@FriendlyCosmonaut I debugged and blackAlpha never gets updated to more than 0.10, so that's why the transition didn't work, because the if statement didnt' meet the condition of blackAlpha >= 1, so room_goto(spawnRoom) wasn't used.
My room transitions aren't working, the character just collides with obj_transitions and stays there, any help?
Feel free to send over the code if you are still working on this series :)
I had a problem where my player was changing rooms fine, but the black transitions were not showing. I eventually solved it by removing the code " room_goto(inst.targetRoom); " from the player objects step event
Perhaps this will help someone else with the same problem.
I just cannot figure out why my character wont move after the transition. it's hopeless.
Couldn't you leave off draw_set_alpha(1) when handling the fade? Every frame, the alpha is being increased until it reaches one. no reason to set it to one at the end of the script every time...
Another great tutorial covering a lot of little tricks for the transition. Great job!
Thank you :)!!
The fading effect only works once... I wonder what's going on. I appreciate any help...
If an object isn't persistent, it won't move on to the next room. Maybe your fade object isn't set to persistent yet
whenever I go between the rooms, im seeing the background of the new room, but my player is not showing up in the new room. Any idea why that would be happening?
That sounds like the room transition is happening correctly, but the respawning of the player isn't. I'd check all the variables and code involved in respawning the player (usually things like this can be as simple as a spelling/grammar mistake). If you can't find it, feel free to send me your project file (file -> export project) and send it to friendlycosmonaut@gmail.com
I have faced the same problem. Maybe someone will find my suggestions useful.
1. Make sure you have a background set in your house room, (just a flat black color for example, i personally created a filled with black "background" layer to solve this problem ).
2. Make sure you have house's entrance trigger TargetX and TargetY set properly (choose the coordinates inside of your house room, where you want your player to spawn).
3. Make sure you have made a camera persistent.
I'm using the tileset you provided to make the room interior, and I'm trying to use the technique you showed us for animating tiles in a tileset. But I'm having an issue trying to animate the clock and the stove. When I go to the Tile Animation area for the tileset, I can only set one FPS for the entire set. I'd like the clock to move at 1 FPS but the stove to move at 5 or 6. How do I accomplish that?
Yeah the FPS you set is shared by all the tiles. A way around this is to set it at the "fastest" FPS you need, and then for the slower ones, just fill up the frames with the same picture to make it seem like the animation is slower.
Lovely tutorials! My GUI dimensions are coming up smaller than my viewport and I can't figure out why. I've followed along super closely. Has anyone else had this issue, or anyone know what I could try? I'm really scratching my head on this one!
I actually had the same problem, but I found a solution to this! Before your code, in the Draw GUI, try typing in:
display_set_gui_maximize();
@@clarisse9170 Funny enough, I just found that solution a couple days ago! It comes up again in a view videos when we do the day/night cycle and the lighting. I actually put it on the game object Create event. Something seems fishy about it, but it does appear to work fine. Must have something to do with different computers/monitors and screen resolutions? :shrug:
@@rreeppeeaatteerr really helped me out here, thank you so much! working on a non-pixel art game so my dimensions for these videos are all sorts of different, lol
in my game world when I move my MC next to a npc he's behind the NPC any fix?
Hi, great video. My idea about spawn is using another object as spawn point with assigned variables facing and spawnName, then you need only store in persistent game instance 'targetSpawnName' because all others value are assigned on spawn object and object position you can use x,y for player spawn position.
// Room start event
//obj_player.x = spawnX;
//obj_player.y = spawnY;
var i;
for (i = 0; i < instance_number(obj_spawn); i += 1)
{
var spawn = instance_find(obj_spawn,i);
if (spawn.spawnName == game.targetSpawnName)
{
obj_player.x = spawn.x;
obj_player.y = spawn.y;
obj_player.facing = spawn.facingDir;
exit;
}
}
Great job with GM2 tutorials btw. ;)
Very nice!!
For some reason blackAlpha is not increasing when I touch obj_transition. I've checked over all the variables and they're consistent. I'm completely stumped.
Never mind it was one lousy curly brace that was very easy to miss.
I am having an issue coding the transition for entering into the house. I have checked over my code and re-watched the video, with nothing seeming amiss. The transition to the forest and back to the farm works fine. However, the one to the house is having issues. I get a fatal error in the Room Start event for the game object. It lists:
"Unable to find any instance for object index '1' name 'obj_player'
at gml_Object_game_Other_4 (line 4) - obj_player.y = spawnY"
I have looked over that section of the code and there seems to be no irregularity. Could anyone give me any advice regarding the matter? I cannot fathom why the code would work for the transition to the forest but not the house.
Hey. It means your character object gets deleted before it can be read - there is a simple fix for it.
1. Go to Objects > Characters > obj_player (or wherever your obj_player is located at)
2. Double-click it
3. Below "Collision Mask", there are four tickboxes
4. Tick Persistent
Have fun coding!
@@Karazaro That worked! Thank you very much, I have thoroughly been enjoying the coding.
But I have another issue as well. When I enter the farmhouse, (either from upstairs or downstairs), there remains a still image behind it. When I enter the farmhouse from the farm, it shows a background of the rm_forest for some reason behind the farmhouse room itself. When I enter it from the upstairs, it shows the last image displayed in rm_farmhouse_upstairs behind the farmhouse (i.e., a still image of obj_player colliding with the stair transition area). Any idea what might be causing it?
@@haydencarlson2746 At first glance, it looks like your camera object is not moving properly. Try to look up the episode where she created room 0 first and how she made objects change rooms from it! :)
@@Karazaro I'll check it out. Thank you again!
@@Karazaro I'll check it out. Thank you again!
What if you have both a run and walk animation?
I coded it like this
if (moveX 2 ) y_frame = 5; //RIGHT RUN
else if (moveX > 0 ) y_frame = 1; //RIGHT
else if (moveY 2 ) y_frame = 4; //Down RUN
else if (moveY > 0 ) y_frame = 0; //Down
else x_frame = 0; //STOPED
Awesome video 👍👍
Any reason not to put the switch(facing) statement in begin step or regular step before facing gets set? Then its all contained in the player object and you don't need it in your draw event too.
Yeah that sounds like a good way to do it!
Would there be any reason why the transitions would take a bit of time before actually happening? It seems that the first transition thats made happens instantly but after that intial one all other are taking some time to happen and the chacter can still move before the room is changed.
Hmm that's a strange one. That shouldn't be happening. One thing that comes to mind is that you might have ticked rooms as persistent? This would mean that more and more memory is being consumed, causing the game to load slower.
all for a "less than" sign being a "greater than" sign which wouldnt change the doTransition variable back to false.
I have a small problem... I used the 8 directional movement code from another video of yours, so I dont know how to fix the facing problem. If anyone can help, I'd be really thankful
You never stated the problem. :)
For some reason my rectangle won't cover the whole screen, my variables seem to be exactly as what FriendlyCosmonaut has:
obj_game:events:create:
guiWidth = display_get_gui_width();
guiHeight = display_get_gui_height();
obj_game:events:draw gui:
...
draw_rectangle_color(0, 0, guiWidth, guiHeight, c_black, ...
...
FIXED!
I just added display_set_gui_maximize(); to the obj_game create event!
@@freeridin Congratulations
Amazing tutorials! One problem i seem to be having is that dotransition is not registering as true (checked through the debug console) even though inst.targetroom changes appropriatly. I've checked for spelling and my code seems to be spot on with yours so I am really just at a loss. Any help would be appreciated and thanks so much for your hard work!
No worries - could I see a screenshot of the relevant code? (You can send it to me at friendlycosmonaut@gmail.com)
i cant get fades to work or actually draw :(
Here's a huge newbie question for someone: Can you remind me why we are setting so many variables to -1 as their initial value? And how does this differ from setting them to, say, 0 as an initial value? I'm still not thinking like a coder yet...
Great question! I know things like this seem pretty arbitrary - and actually, they are. A lot of the time stuff in programming is done because of convention. And by convention, variables are often initialised as being equal to 0 or -1 or undefined. Those values are sort of supposed to just indicate that the variable hasn't really sorted itself out yet. But there are some quirks in GameMaker where numbers >= 0 are actually used as indexes for things like arrays and data structures (if you run the game in debug mode and have a look at what "value" your data structures are, you'll see a number, not a bunch of numbers like you may be expecting from an ID). So initialising a data structure as being equal to 0 can cause some trouble later on, because if you check for example if that data structure exists, if you've set it to 0, it might think that it actually does (because 0 is a valid value for a data structure in GameMaker).
So that's why setting them to -1 can be a bit "safer". Hope that makes some sense!
ok so i managed to get this working fine however i have the same building in multiple rooms and cant figure out how to get the player to go back to the room it came from because i can only put 1 target room. Any ideas?
So you're saying you have the same instance of the transition object in each room? Remove it and place a new one, so that you can then change the location in that instance.
Remember you're placing the code in the individual instance, not the main object. You should be clicking Creation Code, not Edit Object.
Yeah i am putting it in the creation code. I'll rephrase it.
The building is in village 1. Village 1's target is to go inside the building. Inside the building, the target is to go outside to village 1. However, this same building is in village 2. Village 2's target is to go in the building but because its the same room inside, the transition object still has village 1's target. I need a way to go back to the village it came from. Sorry if its a bit of a bad explanation.
@@rhysh993 ah I get you. So you're treating it as the same building but want it to go back onto to where you came.
So I can think of two solutions. 1) you make a seperate house for the second place to go to, if you're wanting to pretend they are different this is probably best.
2) you could create a variable that is changed by the transition squares going to the house. Then the square in the house has an if function that says if variable = A it runs as going to village A, and if variable = B it goes to village B.
Hmm also, if you're acting like one is a different route to the same exact house, then you could just have a different door, like a trapdoor, that one village is linked to
Those are pretty good ideas although creating separate houses may be an issue because im gonna need more than two (as i need them for more villages later on) so although that solution would work and i can easily do it, it will just leave me with lots of rooms, taking up space.
The second option, well I'm relatively new to game maker so i honestly have no idea as to how i would go about making the variables do as intended (i tried before and it was just not working). So if you had any ideas as to how to go about doing it, it would really be appreciated
As for the third option, there's only one door to the building so making another door is not an option
@@rhysh993 I'm reaaaaaaaaaaaally not an expert, I'm just doing the tutorials like you. And I can't do this on mine coz I'm scared this will break it, but have a go with my solution below, and debug it for practise lol
But if you take this bit from the player step screen
var inst = instance_place(x,y,obj_transitions);
if(inst != noone and facing == inst.playerFacingBefore) {
with(game){
if(!dotransition){
spawnRoom =inst.targetRoom;
spawnX = inst.targetX;
spawnY = inst.targetY;
spawnPlayerFacing = inst.playerFacingAfter;
dotransition = true;
}
}
}
This is where the transition happens. So. In the player create (edit: maybe this needs to be in the game object? Try player first) make a new variable, say
last_room = -1;
then in the creator for each instance of the transitions to the house, you want them to have a variable.
room_from = villageA;
for example.
Then you want to add a section into the player transition section above that changes the player last_room variable to the room from
so under spawnRoom = inst.targetroom;
write
last_room = inst.room_from;
This will change the variable in the player to the room that it's just come from
OK, so we can see in the main player transition that we need the inst.targetRoom, the targetX and targetY. So
in the transition that you need inside the house to go to multiple places, go to the creation code. It should be
targetRoom = rm_farm;
targetX = 1006;
targetY = 696;
playerFacingAfter = dir.up;
playerFacingBefore = dir.up;
Well now all you need to do is say "If last_room = villageA then do all this for villageA, if last_room is village B, then do all this for village B.
so for example if my two villages are rm_farm and rm_farmB
if last_room = villageA
{
targetRoom = rm_farm;
targetX = 1006;
targetY = 696;
playerFacingAfter = dir.up;
playerFacingBefore = dir.up;
}
else if last_room = villageB
{
targetRoom = rm_farmB;
targetX = 1006;
targetY = 696;
playerFacingAfter = dir.up;
playerFacingBefore = dir.up;
}
So if we think it through, as you transition INTO the house, you change a variable to say "This is the last room I was in" (and you won't have this changed by different rooms in your house, it will just stay the same). Then when you leave you're saying "If the last room I was in was this, send meto this place, if it was this other one, send me there."
Hope that helps, let me know, and sorry if it doesn't lol I'm really not great at this.
As an aside, I don't think your game would get too big from just having different houses. dunno if this is possible, but you could maybe have an object that's a house, and then in each house room, you place that, and it's basically a premade house, and then you just add extras, or changes on top of it. The problem will be that if you do as planned, each house won't just look the same, it will BE the same, so at that point, what's the point in having them all?
love your tutorial thanks a lot and keep going with this awesome work :)
Thanks for the video. Still so helpful even after so many years)
Can somebody please help me to grasp the logic of Room Start Event - the player's facing is set in Room Start Event according to the obj_transition instance's vale, but shouldn't it be then updating by the player's step event since it should be working every frame after the room start and in that event the player's facing should be reset to -1 since moveX and moveY equal 0 so the facing should be changed again after Room Start Event. I don't get why it isn't happening :'((
was stuck with the fast part between 'game' , 'obj_player' and 'obj_transition' before realising my brackets should have been closed off before an 'else' DOH. this is what i get for watching this in a tiny popout window
my room change isnt working... >.> i dont really know coding all that well but im thinking its the " inst " . those are the only 3times ive used it so i dont see how it would work anyway... any help would be appreciated :)
var inst (instance_place(x,y, ObjTransition));
if (inst != noone)
room_goto(inst.TargetRoom);
Managed to solve it? Cause Im stuck too :c
The room transitions worked wonderfully, but once I added the fade effect, it stopped working! If anyone has had this problem and knows how to solve it, that'd be nice to hear. Thanks!
I decided not to have the fade effect, and got rid of it, but for some reason, my character is invisible when I enter the next room. I can tell he's in the room, because the camera moves, and I can move back into the other room. I tried making another room to see if he'd be invisible if I move into that one. He was. However, if I move back into the starting room, he is visible again.
@@nickspencer2207 check layers
Did you turn your game object "visible"? If not, the draw events will not perform
@@nickspencer2207 try removing the draw event if you have any. Or, you can always to drawSelf() or something like that, cant really remember but make sure you either do one of those
my character is stuck with the moving forward animation after doing the "case dir" switches
I'd need to see your code, but one guess is - have you put "break" at the end of each case?
don't worry i found out a way to get around it, and i'm pretty far into the tutorial now. thanks for replying :)
Ah, awesome! Too easy :)
I am having the same error, do you remember how you fixed yours?
@@gabrielerossi850 sorry bro its been such a long time
Make sure to check your indenting/brackets!!! I messed mine up and it was confusing me for hours
just throwing it out there again, you rock so much.
Have you ever considered turning this into a Udemy course? It's probably at the same level as most of the one's I've taken - maybe more so because I'm learning a lot! Thank you!
Thank you for another great tutorial!
I don´t know what is happening.. I've been following every step.. but almost anything works..
I must be freaking stupid :(
Is it alright to give you suggestions of what tutorials to do next? If so, would you be up for making a tutorial to a drawing program, something Mario Paint-esque?
Things like the actual drawing, erasing, saving the images, etc.
I noticed that tutorials for these kinds of games are very scarce.
This is a very neat idea! Although I have to say I'm quite focused on this series at the moment. I'll file this idea away though.
Thanks so much for even considering my idea. Your tutorials are one of the best I've seen. Keep it up!
I really like your series, but in a bunch of videos and this one specifically a lot of the code doesn't work anymore.
It would be amazing seeing you do a similair series, but up to date!
I’m having the same issue, this code no longer works unfortunately.
Do you know what doesn’t work for you? Because everything works perfectly well for me
Before starting the video, I saw a link to the unit circle: instant like.
Finished the video: enduring like.
thank you so much for these videos! they've been a great help!
Though I ran into a problem with my transitions as it seems that when I collide with a transition object, it works the first time but if I repeat the collision with the transition object it will place me in the room I am currently in. It'll do this as many time as there are rooms in between my current room and the roomTarget (ex: I have 5 rooms set up, current room is 2nd in the list and roomTarget is 3rd. It'll reload me back in the 2nd room every time I hit the transition object after the first time five times, as if going through all my rooms before landing on the right room)
I'm fairly new to programming and GML in general so I'm not too sure what I did wrong or how to fix this issue? If anyone can offer some advice that would be a real help, thank you!
(also I do have a room0 set up with my meta objects with room_goto_next(); being the first thing in my create event)
EDIT: after a lot of head scratching and looking over my code, it wasn't a problem with the code actually lol
all my rooms were marked "persistent" when they shouldn't have been WHOOPS
I made a major boo boo! I made a bunch of rooms right away and viewed them..this erased everything all folders and instances Now rm_1 and Background are blank! ;(
Idk if I lost it all? I never saved. I shut the game down, I deleted the rooms. I played the game all blank! Do I need to re-do days of work now? Redo all my layers and place things back in or what!
Be extremely careful when making new rooms people!!
I ended up just re-placing every level, instance, collision..all that! :). @FreindlyCosmonaut.
top video!!!
Little Question... hope someone can help me with that... after implementing the switch for facing in the player object my character doesnt animate correctly... up and down works fine but left to right doesnt work anymore, she's still moving but wont show the animation for left/right movement... here's my code for that:
Oh and btw love your Tutorials very much
Nevermind... i put "if" instead of "else if" in the step event of the character :D
possible fix for anyone as dumb as me: make sure you actually placed the game object in your starting room! i forgot to do this lol
And to make sure rm_0 is on the top... LOL
than make sure you add background in rm_house ... LOL
@@hoenif I REMEMBER WHEN I DID THAT OMG I WAS SO CONFUSED
bless you...
I had the problem that the teleport did not teleport me into the house but to the teleport point outside the house. Then I realized that the teleporter from outside has teleported right into the teleporter inside. And the inside teleporter kicks me back outside. Omfg 2h of Brainfuck. Hate my life.
So the code isn't working for me plz help:
Step Event (oPlayer):
var inst = instance_place(x,y,oTransition);
if (inst != noone){
with (oGame){
spawnRoom = inst.targetRoom;
doTransition = true;
}
}
Draw GUI(oGame):
if(doTransition){
//Handle Black Fade/Room Transition
if (room != spawnRoom){
blackAlpha += 0.1;
if (blackAlpha >= 1){ room_goto (spawnRoom) }
} else {
blackAlpha -= 0.1;
if (blackAlpha
to anyone getting stuck in the transitions, I deleted my target room and recreated it and suddenly it worked :)
my advise is try with one room first before creating your whole village just in case you run into an issue
Hello, can you give me a hand please :D I´m having problem with mooving to 2nd room after finishing fade effect.
In player/step/objects when I change
var inst = instance_place (x, y, obj_transition);
if (inst != noone) {
room_goto(inst.targetRoom);
}
to
var inst = instance_place (x, y, obj_transition);
if (inst != noone) {
with (game) {
spawnRoom = inst.targetRoom;
doTransition = true;
}
}
is the point when I can´t move to another room. Im not getting any errors I can walk trough transition object how long I want. I followed everything in the video 3times :D and still not working
Well you also need the code for actually doing the transition in the *game* object. Everything is set up, but the "doTransition" code might have a problem in it, so have a look at that - or post it here so I can have a look :)
project file: goo.gl/aa9hoH
I guess it will be easier than from screenshots. I did everything as you showed until 22:00. If you figure out, please let me know what I did wrong because I spent hours and got nothing :D //doTransition is set to false in obj_game/create event
Oh goodness sorry for the delay - I've found the bug! I've stumbled across this one a couple times before, you'll probably laugh when you read this:
So the problem is that the game object was not "visible". This means that its draw events will NOT be run - which of course, means the room transition code wasn't running. So just tick "visible" in the object editor and everything will work fine :)
Haha, no worries I´ve been working on sprites since then :D
Damn it :D I´ve been playing with visibility on obj_transition, but not on the actual game objective :D Thank you so much for problem solving :)
I am having the same problem, but not even checking the object to visible solves it :/ Remade the game object copying the code exactly as you did, but nothing works. Help Cosmonaut!
Du skal væra på kjøkkenet å få det ut få det ut! Men mennene tar seg av vaffelkake buisnissen
i can't get the player to look the way i want them, but i guess that is a problem with me using a different animation code.
Heehee. I got 30 minutes in and was trying to figure out what the hell I did wrong. Just needed to unpause :)
FC your tutorials on textboxes and room transitions are amazing and have really helped me, but I've hit a brick wall in my project at changing the direction the player faces after room transitions :(
Long story short I set up my animations in the player object's step event and in the creation event I set his initial direction to down, but now every time I change rooms and my player object is created it runs that little bit of code and he looks down, but I can't get rid of it because I need to tell the game where to face my player when I start the game D:
If anyone can help me I would be really grateful.
Hmm that's a little odd - that create event for the player should be running BEFORE we change its direction. Unfortunately this one's a bit hard to guess, so I may have to see your code to know what's going on. Could you send me some screenshots of the code pertaining to changing the player's direction, or just the whole project file, to friendlycosmonaut@gmail.com?
Thank you so much for offering to help me but I ended up figuring it out after some messing around! I'll write out my solution here just in case anyone has the same problem I did:
I basically just ticked the "persistent" box on my player object so that the initial direction is set when he's created (down) but is then changed to either left, right, up or down depending on which key is pressed, so when I transition through rooms that variable remains the same so if I walk off screen to the right I appear FACING right when I enter the next screen. I realize that I'm a bit limited in that I can't make my character face 90 degrees to the side after a room transition but that doesn't really affect my current project too much.
Anyways thank you so much for these awesome tutorials FC, you're awesome!
And another one! :)
that alpha tip.
thank you!
You can use && instead of and. Great video by the way.
GMS Trial can only have 2 max tile sets. :(
look up the browser version of Photoshop and just put all the images into one image. Make sure the background stays transparent and you save it as the right file. It takes a bit of fiddling afterwords to realign all the tiles if you already have some made, but hey it's free!
👍🏻
12:03
"Should be a quick video"
*2nd longest video so far*
for some reason when i implement the room transition effect it stops it from working?
hmmmmm i've been following along, but i didn't move everything to a separate "game" object because i didn't want transitions, so i kept everything in the player object. so in the Room Start event i've got "if (spawnroom == -1) exit;
playerobject.x = inst.targetX; playerobject.y = inst.targetY;" which seems to work, but when i exit the room to come back to the previous one, it still spawns me in the original spawn point (ie not the inst.targetX/Y). any ideas?
I'm sure I have written up the code the same way, but I walk through the transition object and don't move tot he next room, any help please?
I had the same problem and fixed it by duplicating rm_farm rather than making a new room.