Hey guys, for anyone else hitting an unexpected behaviour where collision box doesn't show at 24:30 You might be running a higher IDE version 2.3.1 like me. What you need to do is to look at your right panel, under Rooms Folder, there should be rm_0 and rm_1 created Double click on the house icon to the left, and shift rm_0 to the top. What the game was doing was that it creates the room object top down, and caused rm_1 to be created first, ignoring whatever you were trying to do in rm_0 Hope this helps
When I do this while rm_0 is set to a 1x1 size room, I get a super small window, even though I have the viewport set correctly on both. I can't allow the game world size to be dependent on rm_0 since room size will vary later on. Is there another way to fix this that I'm missing?
Just bumping this comment up for other people using this guide on a new GMS2 build. You will need to assign which room is loaded first in the Rooms folder. Numbering it as rm_o will not place the room before your old room.
I've never seen a tutorial series that has taught me as much useful information as this one. I've also never understood the scripting as well as I have after watching this. Thanks so much for making this series! Also sorry for commenting something similar on every video.
I have been following these tutorials over the last two days, and I cannot thank you enough for your clarity of expression and patience in explanation. You are absolutely incredible at going further and beyond what is strictly needed of creating a game like a Farming RPG, as you go onto to explain all sorts of useful things. I'm not explaining myself very well here (the irony!), but like how you showed us how to draw different sprites from one obj_NPC or obj_player was incredible, because I'd been looking for how to do that and had gotten frustrated when trying to. What I am trying to say is that by following this tutorial, I am not only able to create a Farming RPG that I am already proud of so far and showing to my friends and family, but it's also teaching me the core components necessary for just about any RPG or any game for that matter. You've really, really helped me and I look forward to watching the rest of the videos. Thanks so much FriendlyCosmonaut!
I just wanted to say THANK YOU! Your videos have been an incredible resource. I am working on building my first production quality game, and your videos have helped me immensely to better understand GML, and all of the awesome ways we can play with it. You're an amazing teacher. You have a new permanent subscriber. :)
Always learning interesting new things in your videos. Thanks for covering farming RPG's. Been very curious on this genre since playing Stardew Valley :)
@@FriendlyCosmonaut Year later and im taking advantage of this series. Curious to see how far you take it. I'm relatively new to game maker but I have some decent experience with c# using unity. Definitely an amateur over all though so i'm trying to see what game maker allows me to do and this series is good. Not to mention I too am a huge fan of stardew valley! If only I could draw pixel art! haha.
Only came across you Ch while was looking up about depth in GMS2 and found your great tut on the subject! Just wanted to say - thanks for great vids and keep up the great work !!
Ma'am i think you are one of the best teachers for this kind of things , i swer your way of explaining things is awsome and make me want to hear more of your usefull informations :3
FYI if you set the game object to not be visible (reflex from other tutorials that I've done) then the draw event won't trigger. This was the reason I couldn't get my bounding boxes showing.
I love these tutorials! The code is getting a bit more complex, but I still understand a fair chunk of it. :) I do have to say that I'm glad your more recent tutorials seem to enlarge the text size of the code editor. In this video, I couldn't get my code working at one point because a line used square brackets [ ] instead of curled ones ( ) and I couldn't tell the difference from my screen. That took me a while to figure out what was wrong, but I did! Anyway, thanks for the helpful tutorials and great explanations.
Yes I can't even watch a lot of my earlier videos because of how much the audio quality has changed and the fact that the editors are so zoomed out you can barely read it (certainly not on anything lower than 1080p). Anyway, I'm really glad you're powering through them and enjoying the content!! :)
I'm really enjoying this tutorial series and cannot wait to see where you take us next. It's looking really good so far. Thank you for doing this. I'm really looking forward to the next episode.
For the people who are having "Persistent Object" is not working with the latest version of Gamemaker, just simply make that 1x1 pixel room your main room. Otherwise your "game" object will not be working in any way
Hi Cosmo, Did I miss a part in this series where you gave all your room objects from the terrain tile collision masks? When I created my room, I just used the brush to whack a bunch of barrels and bushes but they're not objects. I can see in your resource panel that you don't have any objects like that so I'm a bit confused. Cheers and I'm so grateful for your tutorials.
If anyone is wondering why this is, I did in fact miss a bit. The last 5 minutes of the previous video goes through it all. I must've paused it for some reason and forgot I didn't finish the video.
Small bug shown at the end where if you walk past an NPC you the player is drawn behind them. I would like to know how this is solved as you can't always say the y value dictates the depth.
A name suggestion for the "Meta" folder: "Utilities" or "Utils". Since the collision sprite is purely a development utility, it's a pretty sensible name for the folder.
at around 1:20 you said to share if you have ideas for what to name the group of sprites like the invisible collision object. I used "Utility" - similar to the catch-all Utility namespace I use in C#. Should work for any class (or sprite) that doesn't have a more clearly definable niche. Also thanks for the vid!
Hey guys, for anyone else hitting an unexpected behaviour where collision box doesn't show at 24:30 You might be running a higher IDE version 2.3.1 like me. What you need to do is to look at your right panel, under Rooms Folder, there should be rm_0 and rm_1 created Double click on the house icon to the left, and shift rm_0 to the top. What the game was doing was that it creates the room object top down, and caused rm_1 to be created first, ignoring whatever you were trying to do in rm_0 Hope this helps
I'm having a trouble with the shadow- As far as I know I've done everything exactly like the tutorial, but for some reason the shadow is off to the side and down. I've even completely redid it but still the same. I can't figure out where I went wrong. Edit: After some fiddling, I can 'fix' it by messing with the origin of the shadow. I have to set it off to the side and up and that seems to work for now. I'm just not sure why it's like that. Edit2: It was a problem with the collision mask. Sorry, I feel like I'm spamming.
hey all, it's probably the anchor point for the shadow is still hanging out in the top-left corner of the sprite. If you look at the sprite, move the anchor point (little cross-hairs) so that it appears in the centre of the sprite.
*Raises hand* Question, while I was playing around with the NPC's, I found that they can walk through you, but the player can't walk through them. How to fix?
The player checks for collisions with all instances of obj_collision before he/she is allowed to move, that includes all NPCs. So that's why the player can't move through NPCs. When NPCs check for collisions, they also check against all instances of the obj_collision object which includes all other NPCs and any collision blocks that you have placed manually in your room, but not the player! You can manually add an additional check for just the player object to fix this. Note: you could also make the player a child of the obj_collision object, that way he/she is automatically included in the collision checks; however Friendly Cosmonaut mentioned that she didn't want to do this because the player will have a lot of special cases, that's why she didn't do it.
My collision code doesn't work, it hasn't worked since the first collision video, I'm guessing it is outdated but it isn't throwing me an error message.. Can anyone help?
You placed the debug, restart and exit hotkeys in the step event, instead of making use of the inbuilt dedicated "Key Pressed" event type. Is there any specific reason for that? Great series btw.
i know this video is years old, but i can't get my debug script to work with goto_room_next, only when i delete that and place the object on room_1 will it work. any idea why?
FriendlyCosmonaut said this in another comment below and it was why my debug stuff wasn't working either "in your project hierarchy, which room comes first? Is it rm_1 and then rm_0? If so -- and I forgot to make this point in the video, which was silly of me because it's very important -- when you run the game, the first room it loads is the first one in your hierarchy. So, if rm_1 is first for you then it is going straight there, and never going to rm_0 where the game object is created." Hope it helps!
As always great video. I really enjoyed the debug, I think it's clever idea to keep your meta objects on separate room so you have everything in one place as other rooms get more clutter. One think I noticed that when the NPC walks into the player character they keep walking through it. Should I make collision parent object for player as well to stop that?
I had to add in create for game, debug = debug_mode as the game wouldn't run without it. but wow i'm learning a ton from you 5 vids in and i'ts been 10 hrs lol have to pause a lot to catch up lol, loving the lessons,
Looking good. Only a minor point here, instead of choose you could use irandom_range(min, max). For the 4 choices it's not a big deal, and choose does have the singular advantage of being able to take nonconsecutive figures (like 0, 90, etc if you were going with a set direction function instead of this switch), but "like random_range, but whole numbers" really describes irandom better than choose, and you don't even mention it.
Haha true, I think I was just in the "zone" of using "choose" because of the previous one. My brain seems to work 5x slower when I'm recording. I have to agree irandom_range would have been better here.
I don't know what it is about the NPC random walking code segment that I've messed up, but it's the only thing I haven't been able to properly activate. I'm in the middle of the crop growing tutorials at this point just hoping and waiting we revise the code for NPCs later because I've watched this one three times and still can't find what I've done wrong ahaha.
Hey pretty late reply but I've been facing this issue too and figured it out. In the Rooms folder, you would see a house icon on the left of one of your rooms. Click on that and drag to change the order of the rooms. rm_0 has to come first in order to be executed and the house icon should be with it.
@@hyperealisticglass honestly appreciated! Getting stuck on code elements I diverted my attention to art assets and dialogue/cutscenes. I ultimately ended up working this out but I didn't genuinely know what made it suddenly work. So this is very helpful for future as the code gets more complex :)
One of my NPC's after adding in the NPC parent movement alarm, appears naked at first when I run the game, and then when they move they are fully clothed. I dont see anything different between his create code and the others
@FriendlyCosmonaut Hello! Fantastic tutorials you got going here. After watching your series I've decided to completely rewrite all of my basic systems I had in place in my game earlier, I feel like I finally UNDERSTAND the code I am writing with your help, rather than just copying it. So thank you! Anyway, I was wondering what could be done to keep the NPC's from walking too far from their original spawn/spot. I don't want them randomly walking away from the town by chance. Is this possible?
Thanks so much, that's awesome to hear!! Ah this is a great idea. It's definitely possible, and I'll probably be implementing something like this in the future tutorials on NPCs. (In the meantime, you could do something like throw in an if check to see if(x >= room_width or x
Sounds great! I'll use that in the meantime, seems like a good "quick-fix" to keep them from running away from me at least, haha. Looking forward to it, thanks again. It's truly brilliant how you respond with such care and detail to everyone who comments on your videos. Highly appreciate your effort.
How would you get NPC's to change rooms independently and to keep track of their position while they are in a different room from yours? I don't know of a tutorial or a read up of anyone actually doing this other than it is in games like Stardew Valley and Harvest Moon.
Yeah this is going to require quite a bit of set up. I know it's a super cool mechanic, but truthfully, it really doesn't have to be done until most other mechanics are set up (day cycles, time, quests, events, room transitions, etc), especially because it's going to rely on those systems. So it's not something that could be done now (where we are in the tutorials). But I WILL be covering it eventually (to be honest, it's going to be quite a long way down the track though). If you're really keen -- and it would take me hours to do a proper write up, so I'll just name concepts and point you in a possible direction -- here's some ideas: You're going to need an object that keeps track of the NPCs, and handles their movement. It would also need to have a sort of "map" of the game world. I would say that making use of data structures like ds_grids is going to be needed here. The "map" or more precisely a grid will be of every point in your rooms (say in blocks of 32 by 32 pixels) the NPCs can occupy. You could combine all the rooms into one grid or have different grids for different rooms. The NPCs would have certain "schedules" where they would have different behaviour depending on the time of day, weather conditions, and what room they're in. Every step, the NPC manager object will need to change where the NPC object SHOULD be -- and you would have ANOTHER grid for this (one that stores the instance id, x position, and y position). You could use "paths", or pathfinding algorithims to do this. You'd only bother actually moving the NPC object if it was supposed to be in a point inside the room you're in, as defined by the boundaries of your grid, ie. by assigning the obj_NPC.x = ds_npcgrid[# *co-ordinate of grid that stores the x position*, *other co-ordinate*]. Otherwise, you would just destroy the NPC since it doesn't have to be drawn anywhere, and you would create it if the player moves to the right room. But you'd still update the NPC grid for where they SHOULD be. Note: as for handling NPCs changing rooms, you could also have "warp point" points in your grid, where the NPC reaches the end of the room: once it gets there, you would "switch grids" (if you were using different grids for different rooms). Those are some pointers. As you can see, it gets really complicated really fast. I'd suggest planning it all out visually on a whiteboard or excel sheet or something. Also, if these concepts are unfamiliar to you (eg. data structures like ds_grids) and you have no idea what I'm talking about, but are still determined, I'd highly suggest reading the documentation on "data structures" (ds_grids, maps, etc), and "paths", to see what they're capable of. Otherwise, I will cover this in the future! It might be a while though. But I'm sure I can't be the first person to approach this topic -- perhaps there's something on the gamemaker subreddit, or official forums, or even specific developer's blog posts (although personally I don't know of one).
If i change the size from rm_0 it changes my resolution to that and it wont change when switching rooms. Does anyone know how to fix this? Best solution i've come up with so far is to just let the room be the same size.
How do you decide when to put "var" in front of a variable, and when not to? I thought I understood the subject but then "debug" was created without a var prefix. Thanks!
Essentially, if a variable is something that doesn't need to exist beyond the immediate script (eg. you don't have to save its value, you're just using it to increment a loop or something), you can declare it as a "temporary" or "local" variable, by using the "var" prefix. This sort of variable is destroyed once the script has run. Variables that are declared WITHOUT the "var" prefix will become "instance" variables, and they will be stored in memory until that object gets destroyed. Since we need the value of our "debug" variable to persist over time, we need it to be an instance variable. Hope that helps. Great question!
Thank you for the detailed response. This video series is amazing, I'm up to lesson 7 by now and am doing things I thought it'd take me weeks to accomplish.
Congratulations! I'm following your tutorial for learning GM 2. I have a trouble, but i can't fix it. I think something in my programming is wrong. When i run the game my characters are invisible, i can only see the yellow rectangle at their feet. When i move it, my player appears, but NPC still remain invisible. I have reviewed the entire tutorial from the first to this video, but i am not able to find my programation mistake. Help me, please.
I was having the same problem--check these things out: -make sure your character sprite is coded to be drawn in the Draw tab along the lines of this: //DRAW CHARACTER SHADOW draw_sprite(spr_shadow,0,x,y); //DRAW CHARACTER draw_sprite_part(spr_player,0,floor(x_frame)*frame_size,y_frame,frame_size,frame_size,xx,yy); -check what your frame_size is set to as well as your x_frame and y_frame. these could be causing the character to be drawn offscreen, this was what my problem was, rather than the characters being invisible. the x_frame and y_frame, if using a character sheet like in the tutorial, can be found through the image editing portion of the program. otherwise if you're just using one sprite, or creating frames for sprites instead of using a sheet, the x and y frame would both be 0. -check the collision mask on your mask sprite for your characters as well as the origin (I keep the origin under the feet) hope this helps
Thank you so much for your tutorials, that's already the second from you that I'm following. But I have some troubles now... I don't know why but my npc does not receive the "inheritance", i think everything is fine I have tried to do it all over again 3 times and nothing appears, it still the "-1" so it stays invisible. And my second problem is that the "game object" does not "persist", the room_goto_next() works fine but the debug & game_restart are not active in rm_1. If someone could help me out that would make my day... thanks in advance
Hey guys, for anyone else hitting an unexpected behaviour where collision box doesn't show at 24:30 You might be running a higher IDE version 2.3.1 like me. What you need to do is to look at your right panel, under Rooms Folder, there should be rm_0 and rm_1 created Double click on the house icon to the left, and shift rm_0 to the top. What the game was doing was that it creates the room object top down, and caused rm_1 to be created first, ignoring whatever you were trying to do in rm_0 Hope this helps
I had an issue with the toggle for the debug mode, so if any of you are also having that same issue here's how to fix it. in the create event for your game object set debug to -1 like this "debug = -1;" then go to your draw event for the same object and type this exactly : if(debug = 1) { with(obj_collision) { draw_rectangle_color(bbox_left, bbox_bottom, bbox_right, bbox_top, c_yellow,c_yellow,c_yellow,c_yellow,true) } with(obj_player) { draw_rectangle_color(bbox_left, bbox_bottom, bbox_right, bbox_top, c_yellow,c_yellow,c_yellow,c_yellow,true) } } What this'll do is change the toggle value for false from 0 to -1. So when whatever key you press to toggle it, will change the number one to the opposite of that same number. Now rather than toggling from true to false you'll toggle from 1 to -1 which can be interpreted as true and false as debug will only ever equal one of those two numbers. now go to your step event and type out : if(keyboard_check_pressed(ord("0"))) { debug = -debug } What this does is allows whichever key you choose, in my case 0, to toggle the debug value from one to negative one and back.
@@KamaruAshamae is your game object placed in the game room, and is the game room the first one that spawns? Since we're using the game object to handle things like transitions, debugging modes, and application variables, if the game object never spawns all the things that rely on those variables won't work. To be sure that the game room is spawning firt, comment out the "goto(next)" line of your game object and then run the game. if the room you spawn in is the game room, then you know it's the first one that has spawned. If you spawn in any of the other rooms then the game room is not the one you are spawning in. To fix this move the game room to the top of your room list.
Hi! I've followed the Tutorial on how to set up the alarm event for the Npc. On the create event I've typed "alarm(1) = 1;" and in the Alarm event I have "alarm(1) = random_range(2.5,4)*room_speed;". But when I go to run the game to test it it gives me an error message of malformed assignment on both and that the "=" is an unexpected expression. Ive checked my code and everything matches exactly in the tutorial. Im not really sure what the problem is. Can anybody help? I'd really appreciate it.
After a little experimenting I think I figured it out. I think. Instead of using " ( ) " around the 1 in both functions I used " [ ] " and now it works. Also, I just wanted to say that I just started learning to code games and even though these videos are about 3 years old there still great learning tools. I'm learning a lot from watching them. Thank you for making these videos.
For some reason having the object game in rm_0 doesn't work for me. I checked persistent, but nothing happens. It goes through to rm_1 just fine when I start the game, but there's no random movement and the commands you made (like restart and quit) won't work. Only way working for me is to have the object in rm_1..
Hmm I wonder -- in your project hierarchy, which room comes first? Is it rm_1 and then rm_0? If so -- and I forgot to make this point in the video, which was silly of me because it's very important -- when you run the game, the first room it loads is the first one in your hierarchy. So, if rm_1 is first for you then it is going straight there, and never going to rm_0 where the game object is created. I'll make a note of this in the next video, as we're going to go over room transitions.
Excuse me, But I love your videos. I have a Question regarding your Textboxes Tutorials, Do you know how I can use the same object multiple times (on different locations on the level ). It would really help me out (If you already did this in your second tutorial I am so sorry to waste your time but I can't watch it until tomorrow). Thank you!
The only issue I've run into with this video is when I'm standing still, the NPCs will walk over me - completely ignoring my player's collision box. Is there a fix for this?
Ah, I think at this point we haven't added the player to the same "class" as the NPCs. So you could add the player as a child of that parent NPC object - or, what might be cleaner, is to make another parent that they both share, eg. par_character, and make them check for collisions with THAT.
Yo, just a little thing, instead of writing if idle==false, i think you can write if !idle ..... just to have a bit less letters ;) (ok you already use it on !debug)
Haha yeah. I'm just trying to make the point (to beginners) that there are multiple ways to write the same thing. Often the quickest way to write/do something isn't the most readable, so I try to throw in a few examples.
Hey Cosmonaut, if the exit command exits the entire code block, why is the if statement that calls it excluded? Why not just put the if-statement around all the other code in the draw event if it's going to check it anyways?
Do you mean for the "debug" draw code in obj_game? You could do it that way! I think it was literally just a matter of preference, as nesting everything in an if statement usually means you have to tab everything over, and for an event with lots of code it just means everything has less room. In this case, it really didn't matter as there was only a couple lines of code, but it's a personal habit I've gotten into!
I know this was a long time ago, but yeah I meant the debug draw code, & I was confused about how the exit command worked at the time. I remember thinking it would completely cancel the draw event from then on, preventing it from running every step (including the if statement that allowed it to toggle), so I was curious how the if statement was able to continue checking itself every step. In hindsight I have no idea why I thought that.
Yet again .. Superb ..!! :) I think the only thing that will make this series Really Complete, is a Inventory System, which youve not mentioned doing .. Will you be doing a Inventory System.? Better Still ... An Inventory / Crafting System ..! :) btw.. I call my 'META' Folder ... 'SYSTEM' .. :) .. Im Curious .. Is there a reason you didnt use your 'Depth' system with this tutorial ..?? ..
There will definitely be an inventory system :)! That will come after we make our crops. Crafting (if we do it) will be later down the line. As for the depth -- I just haven't gotten to that yet! I'm trying to just see where things "make sense" to put in. I'd do it now, but I really want to get the crops done, as I feel like it's a crucial mechanic to this kind of game. (But I'll definitely go over depth soon.)
Do you have a solution for the Player overlapping NPC's? i.imgur.com/tvJWCfM.png under i.imgur.com/gFWPsRr.png over I can't think of one. Since if you add another collision box to the hair, then that would stop the player from moving towards immovable objects.
Yes! I have a "depth" system I have created that we'll be adding to our game. That'll probably be one of the first things we do after we get the crop system done. If you want to jump ahead, you can watch the videos I've made on this already -- I'm not going to change much. There's two, here's the first one: ruclips.net/video/rcMHwdvEDy0/видео.html Although when we come to doing it in this series I'll probably make the explanation much shorter (we're going to just implement the "optimised" version).
A wise mentor once told me to never expect my code to work. Always expect it to fail. That way you'll never be disappointed and always be pleasantly surprised when it works.
Hey just an fyi room_speed is now legacy. I've changed over to defining this as a macro #macro FRAME_SEC game_get_speed(gamespeed_fps) docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/rooms/general/room_speed.html hope this helps someone :D
Ahhh interesting! Thank you for pointing this out!! From what I gather from the docs page, it might be okay to use it for *getting* the value, but NOT for setting it.
Somehow, the debug setup, game restart and game end do not work for me. When I put the game object in the main room, it works. (When commenting out the room_goto_next(); line.) I do have the object on Persistent, but it doesn't seem persistent. Can anyone help? Maybe a wild guess. :p Thanks in advance!
Hey guys, for anyone else hitting an unexpected behaviour where collision box doesn't show at 24:30
You might be running a higher IDE version 2.3.1 like me.
What you need to do is to look at your right panel, under Rooms Folder, there should be rm_0 and rm_1 created
Double click on the house icon to the left, and shift rm_0 to the top.
What the game was doing was that it creates the room object top down, and caused rm_1 to be created first, ignoring whatever you were trying to do in rm_0
Hope this helps
Thank you! That was driving me crazy. I didn't even know the Room Manager was a thing.
When I do this while rm_0 is set to a 1x1 size room, I get a super small window, even though I have the viewport set correctly on both.
I can't allow the game world size to be dependent on rm_0 since room size will vary later on. Is there another way to fix this that I'm missing?
Found it, had to enable the viewport for it's settings to be correctly applied. Duh :P
Appreciated!
Just bumping this comment up for other people using this guide on a new GMS2 build. You will need to assign which room is loaded first in the Rooms folder. Numbering it as rm_o will not place the room before your old room.
I know it's been a while since this series came out but this is vastly helpful for gamemaker studio 2. Thank you!
Even for old 1.4 =)
I've never seen a tutorial series that has taught me as much useful information as this one. I've also never understood the scripting as well as I have after watching this. Thanks so much for making this series! Also sorry for commenting something similar on every video.
Haha thank you, that's a big compliment :)
I have been following these tutorials over the last two days, and I cannot thank you enough for your clarity of expression and patience in explanation. You are absolutely incredible at going further and beyond what is strictly needed of creating a game like a Farming RPG, as you go onto to explain all sorts of useful things. I'm not explaining myself very well here (the irony!), but like how you showed us how to draw different sprites from one obj_NPC or obj_player was incredible, because I'd been looking for how to do that and had gotten frustrated when trying to.
What I am trying to say is that by following this tutorial, I am not only able to create a Farming RPG that I am already proud of so far and showing to my friends and family, but it's also teaching me the core components necessary for just about any RPG or any game for that matter. You've really, really helped me and I look forward to watching the rest of the videos. Thanks so much FriendlyCosmonaut!
Thank you so much, this is a huge compliment!
This is the best tutorial series I think I have ever seen on GMS2. Thank you so much for your dedication. You are a real professional.
I just wanted to say THANK YOU! Your videos have been an incredible resource. I am working on building my first production quality game, and your videos have helped me immensely to better understand GML, and all of the awesome ways we can play with it. You're an amazing teacher. You have a new permanent subscriber. :)
Thanks so much Jamie, you're very kind! That's literally my whole goal -- I really do hope the tutorials help. Let me know how your game goes!! :)
After two and a half years, still the best tutorial ever!
Actually almost three years.
I absolutely love these tutorials, I have been using GMS1, and everything translates perfectly over!
Always learning interesting new things in your videos. Thanks for covering farming RPG's. Been very curious on this genre since playing Stardew Valley :)
Yeah it's such a fun genre! Thank you for the support.
@@FriendlyCosmonaut Year later and im taking advantage of this series. Curious to see how far you take it. I'm relatively new to game maker but I have some decent experience with c# using unity. Definitely an amateur over all though so i'm trying to see what game maker allows me to do and this series is good. Not to mention I too am a huge fan of stardew valley! If only I could draw pixel art! haha.
Ugh. This series is SO GOOD. Please please keep going! More GameMaker Studio 2 tuts plz
Only came across you Ch while was looking up about depth in GMS2 and found your great tut on the subject! Just wanted to say - thanks for great vids and keep up the great work !!
Hope it helped! Thank you :)
Ma'am i think you are one of the best teachers for this kind of things , i swer your way of explaining things is awsome and make me want to hear more of your usefull informations :3
FYI if you set the game object to not be visible (reflex from other tutorials that I've done) then the draw event won't trigger. This was the reason I couldn't get my bounding boxes showing.
Boy, did this bug me. Thank you for that, a great help.
Thank you
I love these tutorials! The code is getting a bit more complex, but I still understand a fair chunk of it. :) I do have to say that I'm glad your more recent tutorials seem to enlarge the text size of the code editor. In this video, I couldn't get my code working at one point because a line used square brackets [ ] instead of curled ones ( ) and I couldn't tell the difference from my screen. That took me a while to figure out what was wrong, but I did! Anyway, thanks for the helpful tutorials and great explanations.
Yes I can't even watch a lot of my earlier videos because of how much the audio quality has changed and the fact that the editors are so zoomed out you can barely read it (certainly not on anything lower than 1080p). Anyway, I'm really glad you're powering through them and enjoying the content!! :)
This is a great series. Thank you for these videos, they are extremely helpful.
I'm really enjoying this tutorial series and cannot wait to see where you take us next. It's looking really good so far. Thank you for doing this. I'm really looking forward to the next episode.
Thanks! I'm glad you're enjoying the series.
you are the game developer sent by god to enlighten people
For the people who are having "Persistent Object" is not working with the latest version of Gamemaker, just simply make that 1x1 pixel room your main room. Otherwise your "game" object will not be working in any way
Thank you, I was trying to work out why my collision boxes weren't showing! This fixed it.
@@sarahellis4966 I'm really glad it did help someone after months! Keep it up, develop a good game!
I've these tutorials so much. So helpful for learning about gms in general.
Another great video! You're a great teacher; starting to make sense of GMS2.
Can't wait to see your other videos =)
Hi Cosmo,
Did I miss a part in this series where you gave all your room objects from the terrain tile collision masks?
When I created my room, I just used the brush to whack a bunch of barrels and bushes but they're not objects. I can see in your resource panel that you don't have any objects like that so I'm a bit confused. Cheers and I'm so grateful for your tutorials.
If anyone is wondering why this is, I did in fact miss a bit. The last 5 minutes of the previous video goes through it all. I must've paused it for some reason and forgot I didn't finish the video.
Small bug shown at the end where if you walk past an NPC you the player is drawn behind them. I would like to know how this is solved as you can't always say the y value dictates the depth.
same idk either
with you its just too easy :D i downloaded gms2 today but i feel i can do something in my spare time, maybe a game. Thank you!
A name suggestion for the "Meta" folder: "Utilities" or "Utils". Since the collision sprite is purely a development utility, it's a pretty sensible name for the folder.
I'm looking forward to the next tutorial. thanks for teaching.
at around 1:20 you said to share if you have ideas for what to name the group of sprites like the invisible collision object. I used "Utility" - similar to the catch-all Utility namespace I use in C#. Should work for any class (or sprite) that doesn't have a more clearly definable niche. Also thanks for the vid!
Hey when room 0 is my first room of order it doesn't change rooms! it just shows the 1x1 room we made forever. what can i do to fix that
hi, did you set "room_goto_next();" in create event and set game obj to 0room?
Hey guys, for anyone else hitting an unexpected behaviour where collision box doesn't show at 24:30
You might be running a higher IDE version 2.3.1 like me.
What you need to do is to look at your right panel, under Rooms Folder, there should be rm_0 and rm_1 created
Double click on the house icon to the left, and shift rm_0 to the top.
What the game was doing was that it creates the room object top down, and caused rm_1 to be created first, ignoring whatever you were trying to do in rm_0
Hope this helps
@@IceKangChang I f ♥ u lool, helped me out so much
I'm having a trouble with the shadow- As far as I know I've done everything exactly like the tutorial, but for some reason the shadow is off to the side and down. I've even completely redid it but still the same. I can't figure out where I went wrong.
Edit: After some fiddling, I can 'fix' it by messing with the origin of the shadow. I have to set it off to the side and up and that seems to work for now. I'm just not sure why it's like that.
Edit2: It was a problem with the collision mask. Sorry, I feel like I'm spamming.
I'm having the same issue, but I can't figure out what is wrong. Can you elaborate on what you did?
@@azteckt I don't quite remember but I think I changed the collision mask to a different sprite.
you made it a 64x 64 right? thats how I worked around it
hey all, it's probably the anchor point for the shadow is still hanging out in the top-left corner of the sprite. If you look at the sprite, move the anchor point (little cross-hairs) so that it appears in the centre of the sprite.
sorted the spinning however they now walking on the spot any help would be great
Thanks for all your amazing videos so far !! Really helpful with clear and understandable instructions :)
The rectangle approach in debug doesn't work in IDE 2024 6.2
Hands down this is epic!
*Raises hand*
Question, while I was playing around with the NPC's, I found that they can walk through you, but the player can't walk through them. How to fix?
The player checks for collisions with all instances of obj_collision before he/she is allowed to move, that includes all NPCs. So that's why the player can't move through NPCs.
When NPCs check for collisions, they also check against all instances of the obj_collision object which includes all other NPCs and any collision blocks that you have placed manually in your room, but not the player! You can manually add an additional check for just the player object to fix this.
Note: you could also make the player a child of the obj_collision object, that way he/she is automatically included in the collision checks; however Friendly Cosmonaut mentioned that she didn't want to do this because the player will have a lot of special cases, that's why she didn't do it.
@@impossibleexperiments ... You are amazing.
Thank you, it worked!
My collision code doesn't work, it hasn't worked since the first collision video, I'm guessing it is outdated but it isn't throwing me an error message.. Can anyone help?
You placed the debug, restart and exit hotkeys in the step event, instead of making use of the inbuilt dedicated "Key Pressed" event type. Is there any specific reason for that?
Great series btw.
i know this video is years old, but i can't get my debug script to work with goto_room_next, only when i delete that and place the object on room_1 will it work. any idea why?
FriendlyCosmonaut said this in another comment below and it was why my debug stuff wasn't working either "in your project hierarchy, which room comes first? Is it rm_1 and then rm_0? If so -- and I forgot to make this point in the video, which was silly of me because it's very important -- when you run the game, the first room it loads is the first one in your hierarchy. So, if rm_1 is first for you then it is going straight there, and never going to rm_0 where the game object is created." Hope it helps!
@@nelsonpavao3525 honestly i fixed it like 2 hours after i posted and forgot to say anything but thank you! that was the issue!
@@nelsonpavao3525 I was looking for this tip but I figured it out faster :D but its cool that comments sections is also full of helpful people.
As always great video.
I really enjoyed the debug, I think it's clever idea to keep your meta objects on separate room so you have everything in one place as other rooms get more clutter.
One think I noticed that when the NPC walks into the player character they keep walking through it. Should I make collision parent object for player as well to stop that?
Yes you can! I probably should have done that.
I had to add in create for game, debug = debug_mode as the game wouldn't run without it. but wow i'm learning a ton from you 5 vids in and i'ts been 10 hrs lol have to pause a lot to catch up lol, loving the lessons,
Cheers! I'm glad you're enjoying them :)
Does anyone know where the sword and bow sprites are? Ps love you
Looking good. Only a minor point here, instead of choose you could use irandom_range(min, max). For the 4 choices it's not a big deal, and choose does have the singular advantage of being able to take nonconsecutive figures (like 0, 90, etc if you were going with a set direction function instead of this switch), but "like random_range, but whole numbers" really describes irandom better than choose, and you don't even mention it.
Haha true, I think I was just in the "zone" of using "choose" because of the previous one. My brain seems to work 5x slower when I'm recording. I have to agree irandom_range would have been better here.
I don't know what it is about the NPC random walking code segment that I've messed up, but it's the only thing I haven't been able to properly activate. I'm in the middle of the crop growing tutorials at this point just hoping and waiting we revise the code for NPCs later because I've watched this one three times and still can't find what I've done wrong ahaha.
Hey pretty late reply but I've been facing this issue too and figured it out. In the Rooms folder, you would see a house icon on the left of one of your rooms. Click on that and drag to change the order of the rooms. rm_0 has to come first in order to be executed and the house icon should be with it.
@@hyperealisticglass honestly appreciated! Getting stuck on code elements I diverted my attention to art assets and dialogue/cutscenes.
I ultimately ended up working this out but I didn't genuinely know what made it suddenly work. So this is very helpful for future as the code gets more complex :)
One of my NPC's after adding in the NPC parent movement alarm, appears naked at first when I run the game, and then when they move they are fully clothed. I dont see anything different between his create code and the others
Nevermind, it's a problem with the clothing spritesheet.
Good tutorial, keep em coming!
i just call the "meta" folder "utility"
@FriendlyCosmonaut
Hello! Fantastic tutorials you got going here. After watching your series I've decided to completely rewrite all of my basic systems I had in place in my game earlier, I feel like I finally UNDERSTAND the code I am writing with your help, rather than just copying it. So thank you!
Anyway, I was wondering what could be done to keep the NPC's from walking too far from their original spawn/spot. I don't want them randomly walking away from the town by chance. Is this possible?
Thanks so much, that's awesome to hear!! Ah this is a great idea. It's definitely possible, and I'll probably be implementing something like this in the future tutorials on NPCs. (In the meantime, you could do something like throw in an if check to see if(x >= room_width or x
Sounds great! I'll use that in the meantime, seems like a good "quick-fix" to keep them from running away from me at least, haha. Looking forward to it, thanks again. It's truly brilliant how you respond with such care and detail to everyone who comments on your videos. Highly appreciate your effort.
How would you get NPC's to change rooms independently and to keep track of their position while they are in a different room from yours? I don't know of a tutorial or a read up of anyone actually doing this other than it is in games like Stardew Valley and Harvest Moon.
Yeah this is going to require quite a bit of set up. I know it's a super cool mechanic, but truthfully, it really doesn't have to be done until most other mechanics are set up (day cycles, time, quests, events, room transitions, etc), especially because it's going to rely on those systems. So it's not something that could be done now (where we are in the tutorials). But I WILL be covering it eventually (to be honest, it's going to be quite a long way down the track though).
If you're really keen -- and it would take me hours to do a proper write up, so I'll just name concepts and point you in a possible direction -- here's some ideas:
You're going to need an object that keeps track of the NPCs, and handles their movement. It would also need to have a sort of "map" of the game world. I would say that making use of data structures like ds_grids is going to be needed here. The "map" or more precisely a grid will be of every point in your rooms (say in blocks of 32 by 32 pixels) the NPCs can occupy. You could combine all the rooms into one grid or have different grids for different rooms.
The NPCs would have certain "schedules" where they would have different behaviour depending on the time of day, weather conditions, and what room they're in. Every step, the NPC manager object will need to change where the NPC object SHOULD be -- and you would have ANOTHER grid for this (one that stores the instance id, x position, and y position). You could use "paths", or pathfinding algorithims to do this.
You'd only bother actually moving the NPC object if it was supposed to be in a point inside the room you're in, as defined by the boundaries of your grid, ie. by assigning the obj_NPC.x = ds_npcgrid[# *co-ordinate of grid that stores the x position*, *other co-ordinate*]. Otherwise, you would just destroy the NPC since it doesn't have to be drawn anywhere, and you would create it if the player moves to the right room. But you'd still update the NPC grid for where they SHOULD be. Note: as for handling NPCs changing rooms, you could also have "warp point" points in your grid, where the NPC reaches the end of the room: once it gets there, you would "switch grids" (if you were using different grids for different rooms).
Those are some pointers. As you can see, it gets really complicated really fast. I'd suggest planning it all out visually on a whiteboard or excel sheet or something. Also, if these concepts are unfamiliar to you (eg. data structures like ds_grids) and you have no idea what I'm talking about, but are still determined, I'd highly suggest reading the documentation on "data structures" (ds_grids, maps, etc), and "paths", to see what they're capable of.
Otherwise, I will cover this in the future! It might be a while though. But I'm sure I can't be the first person to approach this topic -- perhaps there's something on the gamemaker subreddit, or official forums, or even specific developer's blog posts (although personally I don't know of one).
If i change the size from rm_0 it changes my resolution to that and it wont change when switching rooms. Does anyone know how to fix this? Best solution i've come up with so far is to just let the room be the same size.
Im going through the same thing. Any updates?
How do you decide when to put "var" in front of a variable, and when not to? I thought I understood the subject but then "debug" was created without a var prefix.
Thanks!
Essentially, if a variable is something that doesn't need to exist beyond the immediate script (eg. you don't have to save its value, you're just using it to increment a loop or something), you can declare it as a "temporary" or "local" variable, by using the "var" prefix. This sort of variable is destroyed once the script has run.
Variables that are declared WITHOUT the "var" prefix will become "instance" variables, and they will be stored in memory until that object gets destroyed. Since we need the value of our "debug" variable to persist over time, we need it to be an instance variable.
Hope that helps. Great question!
Thank you for the detailed response. This video series is amazing, I'm up to lesson 7 by now and am doing things I thought it'd take me weeks to accomplish.
any help to where i gone wrong my mpc are just spinning on one spot ?
Congratulations! I'm following your tutorial for learning GM 2. I have a trouble, but i can't fix it. I think something in my programming is wrong. When i run the game my characters are invisible, i can only see the yellow rectangle at their feet. When i move it, my player appears, but NPC still remain invisible.
I have reviewed the entire tutorial from the first to this video, but i am not able to find my programation mistake.
Help me, please.
I was having the same problem--check these things out:
-make sure your character sprite is coded to be drawn in the Draw tab along the lines of this:
//DRAW CHARACTER SHADOW
draw_sprite(spr_shadow,0,x,y);
//DRAW CHARACTER
draw_sprite_part(spr_player,0,floor(x_frame)*frame_size,y_frame,frame_size,frame_size,xx,yy);
-check what your frame_size is set to as well as your x_frame and y_frame. these could be causing the character to be drawn offscreen, this was what my problem was, rather than the characters being invisible. the x_frame and y_frame, if using a character sheet like in the tutorial, can be found through the image editing portion of the program. otherwise if you're just using one sprite, or creating frames for sprites instead of using a sheet, the x and y frame would both be 0.
-check the collision mask on your mask sprite for your characters as well as the origin (I keep the origin under the feet)
hope this helps
Thank you so much for your tutorials, that's already the second from you that I'm following. But I have some troubles now... I don't know why but my npc does not receive the "inheritance", i think everything is fine I have tried to do it all over again 3 times and nothing appears, it still the "-1" so it stays invisible. And my second problem is that the "game object" does not "persist", the room_goto_next() works fine but the debug & game_restart are not active in rm_1. If someone could help me out that would make my day... thanks in advance
did you figure it out?
Hey guys, for anyone else hitting an unexpected behaviour where collision box doesn't show at 24:30
You might be running a higher IDE version 2.3.1 like me.
What you need to do is to look at your right panel, under Rooms Folder, there should be rm_0 and rm_1 created
Double click on the house icon to the left, and shift rm_0 to the top.
What the game was doing was that it creates the room object top down, and caused rm_1 to be created first, ignoring whatever you were trying to do in rm_0
Hope this helps
I had an issue with the toggle for the debug mode, so if any of you are also having that same issue here's how to fix it.
in the create event for your game object set debug to -1 like this "debug = -1;"
then go to your draw event for the same object and type this exactly :
if(debug = 1) {
with(obj_collision) {
draw_rectangle_color(bbox_left, bbox_bottom, bbox_right, bbox_top, c_yellow,c_yellow,c_yellow,c_yellow,true)
}
with(obj_player) {
draw_rectangle_color(bbox_left, bbox_bottom, bbox_right, bbox_top, c_yellow,c_yellow,c_yellow,c_yellow,true)
}
}
What this'll do is change the toggle value for false from 0 to -1. So when whatever key you press to toggle it, will change the number one to the opposite of that same number. Now rather than toggling from true to false you'll toggle from 1 to -1 which can be interpreted as true and false as debug will only ever equal one of those two numbers.
now go to your step event and type out :
if(keyboard_check_pressed(ord("0"))) { debug = -debug }
What this does is allows whichever key you choose, in my case 0, to toggle the debug value from one to negative one and back.
This still hasn't fixed my issue. I'm not sure what to do anymore
@@KamaruAshamae is your game object placed in the game room, and is the game room the first one that spawns? Since we're using the game object to handle things like transitions, debugging modes, and application variables, if the game object never spawns all the things that rely on those variables won't work.
To be sure that the game room is spawning firt, comment out the "goto(next)" line of your game object and then run the game. if the room you spawn in is the game room, then you know it's the first one that has spawned. If you spawn in any of the other rooms then the game room is not the one you are spawning in. To fix this move the game room to the top of your room list.
Hi! I've followed the Tutorial on how to set up the alarm event for the Npc. On the create event I've typed "alarm(1) = 1;" and in the Alarm event I have "alarm(1) = random_range(2.5,4)*room_speed;". But when I go to run the game to test it it gives me an error message of malformed assignment on both and that the "=" is an unexpected expression. Ive checked my code and everything matches exactly in the tutorial. Im not really sure what the problem is. Can anybody help? I'd really appreciate it.
After a little experimenting I think I figured it out. I think. Instead of using " ( ) " around the 1 in both functions I used " [ ] " and now it works. Also, I just wanted to say that I just started learning to code games and even though these videos are about 3 years old there still great learning tools. I'm learning a lot from watching them. Thank you for making these videos.
For some reason having the object game in rm_0 doesn't work for me. I checked persistent, but nothing happens. It goes through to rm_1 just fine when I start the game, but there's no random movement and the commands you made (like restart and quit) won't work. Only way working for me is to have the object in rm_1..
Hmm I wonder -- in your project hierarchy, which room comes first? Is it rm_1 and then rm_0? If so -- and I forgot to make this point in the video, which was silly of me because it's very important -- when you run the game, the first room it loads is the first one in your hierarchy. So, if rm_1 is first for you then it is going straight there, and never going to rm_0 where the game object is created.
I'll make a note of this in the next video, as we're going to go over room transitions.
Excuse me, But I love your videos. I have a Question regarding your Textboxes Tutorials, Do you know how I can use the same object multiple times (on different locations on the level ). It would really help me out (If you already did this in your second tutorial I am so sorry to waste your time but I can't watch it until tomorrow). Thank you!
Yes, it's in the second tutorial!
I have the problem where my player and npm sprites don't appear until I make the character move. How do I fix this?
Another great tut. Thanks so much.
No worries, thanks for watching :)
The only issue I've run into with this video is when I'm standing still, the NPCs will walk over me - completely ignoring my player's collision box. Is there a fix for this?
Ah, I think at this point we haven't added the player to the same "class" as the NPCs. So you could add the player as a child of that parent NPC object - or, what might be cleaner, is to make another parent that they both share, eg. par_character, and make them check for collisions with THAT.
Yo, just a little thing, instead of writing if idle==false, i think you can write if !idle ..... just to have a bit less letters ;)
(ok you already use it on !debug)
Haha yeah. I'm just trying to make the point (to beginners) that there are multiple ways to write the same thing. Often the quickest way to write/do something isn't the most readable, so I try to throw in a few examples.
Hey Cosmonaut, if the exit command exits the entire code block, why is the if statement that calls it excluded? Why not just put the if-statement around all the other code in the draw event if it's going to check it anyways?
Do you mean for the "debug" draw code in obj_game? You could do it that way! I think it was literally just a matter of preference, as nesting everything in an if statement usually means you have to tab everything over, and for an event with lots of code it just means everything has less room. In this case, it really didn't matter as there was only a couple lines of code, but it's a personal habit I've gotten into!
I know this was a long time ago, but yeah I meant the debug draw code, & I was confused about how the exit command worked at the time. I remember thinking it would completely cancel the draw event from then on, preventing it from running every step (including the if statement that allowed it to toggle), so I was curious how the if statement was able to continue checking itself every step. In hindsight I have no idea why I thought that.
EDIT: I fixed my issue, it was stupid...... I'm loving the video btw!
Hehe, no worries. Cheers!
good tutorial, the folder that you put collision in, I called "Main Sprites" or "General Sprites".
Thank you. Always interesting to see how others organise their project.
I usually name mine System
Behind-the-Scenes is alright
Oh hi, fancy seeing you here!
For the folder you called meta I would call it logic.
Yet again .. Superb ..!! :)
I think the only thing that will make this series Really Complete, is a Inventory System, which youve not mentioned doing .. Will you be doing a Inventory System.?
Better Still ... An Inventory / Crafting System ..! :)
btw.. I call my 'META' Folder ... 'SYSTEM' .. :)
..
Im Curious .. Is there a reason you didnt use your 'Depth' system with this tutorial ..??
..
There will definitely be an inventory system :)! That will come after we make our crops. Crafting (if we do it) will be later down the line.
As for the depth -- I just haven't gotten to that yet! I'm trying to just see where things "make sense" to put in. I'd do it now, but I really want to get the crops done, as I feel like it's a crucial mechanic to this kind of game. (But I'll definitely go over depth soon.)
Do you have a solution for the Player overlapping NPC's?
i.imgur.com/tvJWCfM.png under
i.imgur.com/gFWPsRr.png over
I can't think of one. Since if you add another collision box to the hair, then that would stop the player from moving towards immovable objects.
Yes! I have a "depth" system I have created that we'll be adding to our game. That'll probably be one of the first things we do after we get the crop system done. If you want to jump ahead, you can watch the videos I've made on this already -- I'm not going to change much. There's two, here's the first one:
ruclips.net/video/rcMHwdvEDy0/видео.html
Although when we come to doing it in this series I'll probably make the explanation much shorter (we're going to just implement the "optimised" version).
FriendlyCosmonaut !!
You're the best. Going to watch those now! Thank you.
Thanks!
I usually just call my "Meta" folder "System"
It is very great!
I cannot see it well
top!!!
error messages are your friend o.o
oh nononono laugh
A wise mentor once told me to never expect my code to work. Always expect it to fail. That way you'll never be disappointed and always be pleasantly surprised when it works.
Hey just an fyi room_speed is now legacy. I've changed over to defining this as a macro
#macro FRAME_SEC game_get_speed(gamespeed_fps)
docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/rooms/general/room_speed.html
hope this helps someone :D
Ahhh interesting! Thank you for pointing this out!! From what I gather from the docs page, it might be okay to use it for *getting* the value, but NOT for setting it.
FriendlyCosmonaut ah gotcha, thanks for the clarity. Side note, I love the series, keep going, you're doing great :)
Cheers Brendan :)!
Somehow, the debug setup, game restart and game end do not work for me.
When I put the game object in the main room, it works. (When commenting out the room_goto_next(); line.)
I do have the object on Persistent, but it doesn't seem persistent.
Can anyone help?
Maybe a wild guess. :p
Thanks in advance!