Depth System Tutorial: GMS2

Поделиться
HTML-код
  • Опубликовано: 19 сен 2024

Комментарии • 177

  • @FriendlyCosmonaut
    @FriendlyCosmonaut  5 лет назад +31

    Here's a few timestamps, especially if you're an intermediate/advanced user who wants to skip some preamble:
    - 3:19 summary of the first few minutes that lays out the how the system will work conceptually
    - 4:40 start the actual coding/object setup

    • @boonboy8333
      @boonboy8333 4 года назад

      Can you set a sprite depth using a negative number?

    • @AngelloMaggio
      @AngelloMaggio 3 года назад

      @Mladen Markovic Very late, but I think you were missing the draw_self(); in the object's draw itself (the child of par_depthobject)

    • @runafangz
      @runafangz 2 года назад

      @Mladen Markovic also very late but have you put the depthsorter in your room? that was something I didnt do at first and it caused things to be invisible

  • @Atticore
    @Atticore 2 года назад +6

    I spent forever trouble shooting this because I could not get it to work right.
    seems there's a lot you can screw up, but I got it working in the end.
    some observations, from atleast what I could gather in my troubleshooting:
    -the depth sorter must be present in every room you want to use it in.
    -it must be in the same layer as all the objects you want it to sort

  • @Reqcore
    @Reqcore Год назад +1

    I had some struggles getting this to work but I tried things in the comments and noticed I had not placed the depth sorter in the room, then everything worked. Thank you for the video!

  • @thedogshop7561
    @thedogshop7561 5 лет назад +33

    that new intro is so nice (:

  • @mgoface7499
    @mgoface7499 5 лет назад +3

    I basically started looking for it this week, and here you are conveniently uploading it a couple days before that.
    Keep up the great work on this channel. I am an average programmer, but am still toying around with more difficult, game maker specific designs like these.
    Your videos are really helping me learn how to design these system. Thanks for that! :)

  • @Mitometo
    @Mitometo 5 лет назад +15

    If you're struggling with this tutorial, double-check to make sure that the origins of the sprites of all the depth child objects are at the bottom of the image (assuming you're making a top-down game). I forgot to set one of those correctly and it confused me for quite a while.

    • @kazmaka
      @kazmaka 4 года назад +2

      Well that solved a whole bunch of frustration!

    • @JimmyMcGinger
      @JimmyMcGinger 4 года назад +1

      Oh my god thank you

    • @itsjustcullin
      @itsjustcullin 2 года назад +1

      ik this is 2 year late but I'd like to tell you YOU'RE A LITERAL FUCKING GOD

    • @uhh-uhmm
      @uhh-uhmm 6 месяцев назад

      4 YEARS AFTER LOVE YOU

  • @TheAwesomeAlan
    @TheAwesomeAlan 2 года назад +15

    To anyone coming to this video: There's a much, much simpler way to do this currently!
    In the player STEP event, put this at the bottom:
    depth = -bbox_bottom;
    In every object you want to have depth, put this in the CREATE event:
    depth = -bbox_bottom;
    Make sure every object (object's sprite) has a collision box set, and put the origin at the "Bottom Centre" position. Super easy! This won't work with the tileset system, as it will always adjust to your y position and create a new layer on top of that, so use it if you aren't using tiles for any kind of overlays like lighting.

    • @BluBuryPi
      @BluBuryPi 2 года назад +3

      This definitely worked for me. Only now my player won't collide with any object that I have depth enabled on. I'll have to try to sort that out later though. Thanks for the tip

    • @Augoeides32
      @Augoeides32 5 месяцев назад +1

      I was already doing this because of my tutorial, but I didn't quite fully grasp the "depth" of what it was doing, until now. I was taking serious notes from this tutorial, but I guess it wasn't needed. As a quick note, I've found doing a custom collision tile for your object to be more satisfying, than if you just gave the object itself collision; mostly because when the Player collides with object masks it seems to have a weird violent shaking effect that doesn't seem to happen from tiles.

    • @benignexistence4558
      @benignexistence4558 5 месяцев назад

      alternatively, if your sprites origin tends to be bottom-center, depth = -y tends to work in most cases. your suggestion is also good, though.

  • @KifDawg
    @KifDawg 4 года назад +6

    Heavily undervalued channel, you are amazing. You have a serious talent making games and videos. I really hope you keep making content. Love this! Thank you

  • @waywardpooch9567
    @waywardpooch9567 5 лет назад +2

    Thanks for this! I especially appreciate the in-depth rundowns of the smaller things such as variable scope; I didn't know some things before, such as the fact that local variables were lighter on resources vs instance variables, or what ds_grids were even for. Your pacing is perfect. Thank you!

  • @MANNLIERMANNCO
    @MANNLIERMANNCO 5 лет назад +3

    i love the way you went trough explaining the most novice conceptepts fully. thanks!

  • @augustacybersolutions
    @augustacybersolutions 8 месяцев назад +1

    Not sure if you are still out there making content, but thank you for these videos!! they are teaching me a lot

  • @peegion4742
    @peegion4742 Год назад

    This works 100% for isometric tiles (granted your tiles are on the same height). Works in multiplayer (the new OperaGx multiplayer system). In this multiplayer system, you *cannot* manipulate the depth of the player objects, so this tutorial works perfectly for this as well (no depth required). Amazing tutorial!

  • @Sevendogtags
    @Sevendogtags 5 лет назад +4

    Your videos are so high quality and informative. Thank you!

  • @Chris-jl6vp
    @Chris-jl6vp 3 года назад

    I dunno why I keep seeing this crap where people are comparing depth=-y; to this and saying it works the same.
    It doesn't. depth=-y; doesn't update in the creation event, and doing it in step supposedly slows down the system if you have lots of instances because they're all individually running this bit of code.
    Anyhow with that said, this was exactly the tutorial that I was looking for. Thank you so much for making this.

  • @crystalrobinette9323
    @crystalrobinette9323 4 года назад +1

    Thank you SO much Friendly Cosmonaut. I have an armor system and was trying to get a Depth System to work. Had been just randomly skipping around videos and teaching things and lucked out at Event_perform(ev_draw)!

  • @hazu6077
    @hazu6077 2 года назад

    just wanted to share my problem solving on my project (as a new user to GMS2)
    if u have correctly following the coding that Friendlycosmonaut gave but have no depthsort effect, try to look at your sprite collisson mask, and resize it just on the bottom of the sprite, cause by default, the collision mask will cover all of your sprite and GMS will translate it as a whole image when you step on it.
    btw thanks for this tutor @Friendlycosmonaut your explanation really helps me a lot with my project!

  • @kishou5759
    @kishou5759 5 лет назад +10

    The opening is sooooo cute!Really expect your save&load tutorial,always so useful😘

  • @autumn_breeze616
    @autumn_breeze616 4 года назад

    Thank you so much! I had a couple of hiccups since you can only have one parent and I'm already parenting all dialogue objects for my dialogue system, but I was able to work through it! You made a potential headache much less stressful, when I learned GMS2 changed its whole depth-order thing through layers I low-key panicked. The forums didn't help too much either since people were talking about the problem from a performance perspective, which made me assume I'd have to implement some crazy bespoke data structure just to draw sprites in order lol. This was simple, and now I can get back to the other million headaches inherent to my project haha. Great video!

  • @revonine3099
    @revonine3099 3 года назад

    I decided on a whim to watch this while trying to think of a way to sort out turn order in a turn-based rpg and hey the functions you showed here should be perfect for it, thank you so much!

  • @ryarod
    @ryarod 3 года назад

    I currently have GMS1. GMS2 is too expensive for me- these days, at least- and yet I'm going to give GMS2 tutorials a shot . Wish me luck in implementing them.
    This goes especially for this one. I've been looking for a way to control layering/sequencing in GMS1, and I've finally found something. And a something thorough no less.

  • @clanmembers5743
    @clanmembers5743 3 года назад

    in the moment your video started I came to the idea to depent the depth of an npc on the y value, that solved my problem with overlapping npcs. So thank you :)

  • @davidprestenberg5976
    @davidprestenberg5976 2 года назад

    wow you're amazing dude! most people do not explain their code this thoroughly. You really helped me understand a lot more about GML thank you so much

  • @Redpill1980
    @Redpill1980 5 лет назад

    Thank you for this. Very helpful stuff. I had real trouble getting bullets drawing properly though, before realising I was creating using instance create depth rather than layer!

  • @JimmyMcGinger
    @JimmyMcGinger 4 года назад

    Needed a refesher for a jam game, having done the farm one and just wanted to add how great the improvements to your video making are!

  • @msPacmanization
    @msPacmanization 4 года назад +3

    2 things to add:
    1- if you add this system to a game where you have already have create events for child objects, don't forget to add an 'event_inherited()"
    2- you need to add the depthsorter object to the room or it will not work.

    • @AaronAsherRandall
      @AaronAsherRandall 3 года назад +1

      Where do you add the code 'event_inherited()' ? Thank you!

  • @prowokator
    @prowokator 4 года назад +2

    No new Gamemaker videos in a long time? :( I hope all is well, your content is top notch!

  • @vee4603
    @vee4603 5 лет назад

    As always, your work is pure quality. Thank you!

  • @pogostar1878
    @pogostar1878 4 года назад

    Thank you for this video! I have been struggling with this concept for days, and this helped immensely!

  • @onithedemon
    @onithedemon 3 года назад +15

    I think I found an easier way to do it and I believe it's more efficient because you don't have to sort any list.
    Set the background depth to: room_height and write in the step event of the instances you want to update:
    depth = room_height - y;
    And that's all.

    • @DarkEspeon40K
      @DarkEspeon40K 2 года назад +2

      That is fucking genius

    • @Coxyworthy
      @Coxyworthy 2 года назад +10

      This works BUT when you are changing an objects depth on the fly like this you are actually creating new layers which can be very bad for memory depending on the number of objects in a room. Here is a forum post that goes into "depth" about the subject: forum.yoyogames.com/index.php?threads/depth-ordering-in-gms2-priority-list-nested-list-grid-binary-list.13425/

    • @onithedemon
      @onithedemon 2 года назад +1

      @@Coxyworthy F

    • @cicada_games
      @cicada_games Год назад +1

      @@DarkEspeon40K Unfortunately it's actually quite bad / inefficient in gamemaker. As the other comment points out, gamemaker creates new custom layers every time you set depth manually. For a game like this, it would probably ruin performance.

    • @roz9738
      @roz9738 11 месяцев назад +2

      THANK GOD FOR THIS COMMENT. I was having issues for AGES. You sir are a saint.

  • @DanTheAssassin
    @DanTheAssassin 5 лет назад

    Your tutorials are really great! Really help me a lot to progress with my game!

  • @CFALOFFICAL
    @CFALOFFICAL 4 года назад +9

    What if the Y-positions match, will there be a 'z-fighting' type situation? And, can different sized sprites be used?

    • @mouthfulofchlorine
      @mouthfulofchlorine 2 года назад +1

      if the y positions match, whichever instance was added first to the grid will be drawn
      this comes down to which instance was created first basically

  • @CopyCopyOriginal
    @CopyCopyOriginal 2 года назад +1

    what if you had a 'raised tile layer' or different heights? objects will still draw inappropriately beneath those raised layers with this strat :(

  • @fattcoke4705
    @fattcoke4705 Год назад

    This worked perfectly for me. FriendlyCosmonaut never fails.

  • @jonasjaggard976
    @jonasjaggard976 4 года назад

    WOW! thank you so much. Although I practically just copied your code, you are an excellent teacher and I was still able to understand what all the code meant.

  • @MetaHootOriginals
    @MetaHootOriginals 5 лет назад +1

    Ahh thank you thank you this is great just what i needed.I really love your channel and hope you finish your farming series and maybe you can make an end credit tutorial for an upload.

  • @JonnoBones
    @JonnoBones 5 лет назад +5

    Is there any benefit of using this system over just making the object's depth = -y ?

    • @PixelatedPope
      @PixelatedPope 5 лет назад +10

      Being able to continue to use the layer system. So you will always know which layers are above a depth sorting object and which layers are below. If you use depth = -y, you've removed the object from the layers.

    • @JonnoBones
      @JonnoBones 5 лет назад +1

      @@PixelatedPope That's good to know. Thanks.

  • @PGtheVRguy
    @PGtheVRguy 3 года назад

    I swear RUclips is spying on me. I was just thinking to myself "how do people make it so no weird overlap happens" then right when I enter RUclips this tutorial appears.
    Thank you

  • @Burindoru
    @Burindoru 3 года назад +3

    This is awesome. Implemented pretty well - Having a few issues - It doesn't seem to like it if elements are different heights - works well for similar height sprites, two that are different it won't kick in until halfway up (say a tall pillar). As it seems to work out from the origin point (which is center center for my project). Tried with all sprites set to center bottom or top left and no luck. Really would love to get this working well. Is there any way to get this working for sprites with different heights? For some reason I thought it would be doing the calculation from the sprites bottom image y value. Perhaps that will work better. :)

    • @Burindoru
      @Burindoru 3 года назад +4

      For anyone else hunting this that's using mixed sized sprite - it can be done with getting the 'bbox_bottom' value in place of the default y (which defaults to origin point) for each instance. Instead using the y from the actual bottom edge of the sprite mask.
      replace the line in draw event from "dgrid[# 1,yy] = y;" to "dgrid[# 1,yy]= bbox_bottom;"
      more info in the manual at
      docs.yoyogames.com/index.html?page=source%2Fdadiospice%2F002_reference%2Fgame%20assets%2Fsprites%2Fsprite_get_bbox_left.html

  • @gimligimlass5509
    @gimligimlass5509 3 года назад +2

    Does using the data structure create a noticable inpact on performance compared to just setting the depth to [depth = -y;] in the create or step event?

  • @rinkun6689
    @rinkun6689 5 лет назад +2

    Can't wait for your rpg battle system tutorial cx

  • @Jesse_Lacerda
    @Jesse_Lacerda 10 месяцев назад +1

    What if i want to sort some objects in a specific order when they share the same Y?

  • @1HardCoreGaming1
    @1HardCoreGaming1 5 лет назад +11

    I've gone over this tutorial, AND your previous two tutorials, Shaun Spaulding's tutorial, and a few others that i've found. I CANNOT GET THIS TO WORK.
    I am using the basic character creation from your farm series, then went ahead and tried fixing the depth between my player and my objects, and for the life of me I just can't get this to work. I've tried everything. All the code is the same, i've been at this for a week now, and I just can't figure out why it's not working. I really need help. :( This is the first major roadblock i've hit in my game and I have no clue how to fix it or make it work.
    I've gone through every one of these videos countless times... Nothing is any different. I don't know why my depth system isn't working. But my character just walks all over the objects as if his depth is not changing at all, and is at a static high number.
    EDIT: If anyone has this problem, make sure your objects origin points are at BOTTOM CENTER, and not TOP LEFT (0, 0). Problem fixed. :)

    • @svenjorgensen5
      @svenjorgensen5 5 лет назад +2

      This tutorial is way overcomplicated. Just place this in your player's step event: depth = -y;
      Then place the same thing in each object's create event: depth = -y;
      Voila, same effect.

    • @worldofexplorers
      @worldofexplorers 4 года назад +2

      @@svenjorgensen5 You do understand that this dynamically creates instance layers and is slow as all fuck ?

    • @worldofexplorers
      @worldofexplorers 4 года назад +4

      @@svenjorgensen5 Anything "over complicated" in programming is usually essential and for the sake of optimizations.

    • @spiritblue5139
      @spiritblue5139 4 года назад +2

      @@worldofexplorers hes just bad at programming.

    • @svenjorgensen5
      @svenjorgensen5 4 года назад +3

      @TheGameDevGuy you would only use this on the instances you'd want to dynamic depth on. I have not seen a measurable effect performance-wise using this method.
      >Anything "over complicated" in programming is usually essential and for the sake of optimizations.
      I've seen too much ridiculous spaghetti code to agree with this. Furthermore, are you going to defend her terrain collision system that involves creating tons of extra instances in the room instead of a tile-based system?

  • @pablonaranjogutierrez3831
    @pablonaranjogutierrez3831 5 лет назад

    Hi! Thank you so much for the detailed explanation of depth sorting. I managed to have this working on an isometric demo I'm doing. Worked great! Subscribed and will definitely see more of your videos! :)

  • @didigo8424
    @didigo8424 4 месяца назад

    thank you so much, i want to hug you

  • @stegeflott
    @stegeflott 2 года назад +1

    This is a great depth system...
    But how would i set it up so my character could carry something like a gun/bow. and that object is infront of the
    player at all time but it would still be behind other objects ..
    I can rotate the gun 360degrees but when the gun is over 90 it starts to be behind the player. I create the gun at the origin of the player.
    I would like the gun object to be infront of the whole player and work with the depth system on all other objects??

  • @SGTIvan921
    @SGTIvan921 11 месяцев назад

    Timestamps for reference:
    3:49 How it works (pause here)
    4:40 Create a parent depth object and disable all the draw event by making the objects as children of that parent
    6:00 Create a depthsorter object (using a data structure to keep track of the objects)
    6:57 Instance ids kept on first column, y positions kept on second column; the y positions will be organised in order
    7:29 ds_depthgrid = ds_grid_create(2, ___) (we need to find the number of instances in the room later on)
    9:18 Manual disposal of the data structure in a Clean Up event - necessary since ds_grids do not do this automatically
    9:57 Resizing the grid in the draw event
    10:37 Finding the number of instances in the parent depth object using instance_number(par_depthobject);
    12:27 Get the instance information using a with statement
    13:38 Two ways of adding to a grid [ds_grid_add() and using the # accessor]
    14:55 Control the y value in the accessor using a local variable which we can increment for every child added. Then, yy will just be incrementing (if yy = 1, then it's the 2nd row) and putting in the names of the instances into the grid.
    15:54 Important brief note on local variables vs instance variable when naming the yy variable
    16:31 Local variables will be limited to the scope of that script
    17:11 Adding the second column: adding the y positions. [***17:32 replace y with bbox_bottom]
    18:45 Sorting the grid: use of ds_grid_sort()
    19:41 Draw the instances using a repeat loop (the times is determined by the number of instances)
    21:37 Drawing the instances
    22:36 You can use event_perform(ev_draw, 0) in order to run the draw event of each instance instead of simply draw_self(). But...
    23:45 New problem: everything's gone! Why? It's because the objects do not have a draw event. What's the solution?
    24:17 Solution: put a draw event on the parent depthobject with draw_self() inside it.
    Additional remarks:
    1. Add the depthsorter object to the room or this will not work.
    2. This depthsorter is especially helpful for isometric tiles, according to another commenter
    3. According to another commenter, a simple way would be that you can put depth = -bbox_bottom in step event of the player and depth = -bbbox_bottom in the create event for all the objects that you want to have depth. The origin should be at the bottom centre position. A reply said that the player won't collide with any object with depth enabled.
    4. Another commenter mentioned: dgrid[# 1,yy] = y; should be replaced with dgrid[# 1,yy]= bbox_bottom; this is better especially when you have mixed sized sprites. It takes the actual bottom of the sprite instead of the origin of the sprite.

  • @PixelatedPope
    @PixelatedPope 5 лет назад +3

    Why not use a priority queue instead of a data grid?

    • @FriendlyCosmonaut
      @FriendlyCosmonaut  5 лет назад +3

      Haha. Short answer? Two years ago, Ariak persuaded me that grids were more performant.
      Longer answer? Two years later, I still love thinking about concepts using grids and prefer to use them when I can. I don't find much value in doing things for little performance changes, so wouldn't want to use that argument. I'd much prefer (and advise others) to use the structure/method that you personally understand better/feel is neater etc. So if anyone reading this prefers priority queues and wants to use them and/or is wondering why I didn't, use the one you want! They both get the job done :)

    • @PixelatedPope
      @PixelatedPope 5 лет назад +2

      @@FriendlyCosmonaut I use to use ds_grids for almost EVERYTHING (like the coins in my save data tutorial), but I've definitely been moving away from them for the most part.

  • @valandilluinwe7332
    @valandilluinwe7332 4 года назад

    thanks @FriendlyCosmonaut

  • @pelicanmaniac
    @pelicanmaniac 4 года назад +1

    I followed this tutorial perfectly, but my player object would always overlap with the rest of my objects! After a few frustrating minutes, I figured out it was because my player had a different Y origin than the objects. I.E. my other object's origin was TOP LEFT and my player was BOTTOM CENTER. Changing them both to BOTTOM CENTER fixed the issue.
    Also noticed that this cancels out any draw_gui events because the object is set to invisible. Any way around this?

  • @rascalnicough7376
    @rascalnicough7376 3 года назад

    Exactly what I needed and I learned a lot -- thanks!

  • @NightShade-sc4wr
    @NightShade-sc4wr 2 года назад

    Thank you so much! This video really helped me understand how Data structures work :)

  • @pelicanmaniac
    @pelicanmaniac 4 года назад +1

    Is there a way to get depth sorting on multiple instance layers? With this method, it seems like it put all instances on the same layer, as far as I can see. Like, I want to have a layer for flying instances (like birds) that sort their depth among themselves, but they will always appear above instances that are on the ground.

    • @roz9738
      @roz9738 11 месяцев назад

      Did you ever figure it out?

    • @pelicanmaniac
      @pelicanmaniac 11 месяцев назад

      ⁠@@roz9738i made a system where flying instances were subtracted their depth from the room height.
      I think I had a global variable called fly_level which was set to like -999. Then like all flying instances’ depth = depth - room_height + fly_level

  • @alessandropisa7018
    @alessandropisa7018 4 года назад

    your code ignites my light

  • @benvictim
    @benvictim 5 лет назад +1

    Thanks for the great video! Only problem I see is that all objects are now tied to the depth of the depthsorter. With this type of system, how would you handle a player being able to walk under and on a bridge? Or would you just stick the as an object instead of trying to have it be tiles?

    • @Musikur
      @Musikur 2 года назад +1

      You can specify a tile layer at a higher layer; all of the objects on this layer are at 0 depth.

  • @ianfrankproductions4004
    @ianfrankproductions4004 3 года назад +1

    I like this system, and are using it in my current project. However, the issue with objects at the same y coordinate persists. They flicker and trade place during the list sorting. Just try to position 2-3 overlapping objects at the same y-level, then move your character around to see the issue. Does anyone have a proper solution for this? :-)

  • @Jprobloxbr
    @Jprobloxbr 3 года назад +1

    Thx!

  • @LadenIsle
    @LadenIsle 5 лет назад +2

    You are very under-subscribed

  • @gazzolapw
    @gazzolapw 4 года назад

    Ok this could be sound stupid, but It took me literally 2hs to understand what I was doing wrong.
    My code wasnt working in several ways, basically nothing is draw on the game when I run it or I have some error on the draw_self() at 22:00.
    Its was not easy to get it by watching the vidio, but the only object you need on the game room is the obj_depthSorter, keep the parent object out of the room (All other objects like player, trees etc should also be on the room)
    Now its working great, thanks for the awe tutorial.

  • @thomasrosebrough9062
    @thomasrosebrough9062 3 года назад

    Great video, i was wondering tho why you used a ds_grid instead of a ds_list? is it just for the sorting step?

  • @pedroantonio743
    @pedroantonio743 5 лет назад +2

    what is the disadvantage of using depth = -y?

    • @FriendlyCosmonaut
      @FriendlyCosmonaut  5 лет назад +3

      Nothing wrong with depth = -y at all, but it does mean it's a bit more complicated to keep the room layers system intact (the instances will no longer be on the Instances layer you put them in at first, when you change their depth, they'll go in their own layer). It can be helpful to keep these layers in eg. for deactivating/reactivating instances in a particular layer. This can also make it easy to apply a bunch of effects to the instances (eg. a shader) because they're all drawing at the same time. That said, all this is possible in other methods, it's just one way to do it!

    • @dorian8050
      @dorian8050 4 года назад +1

      @@FriendlyCosmonaut Hey, I was thinking, how about depth -= y in the creation event? Couldn't this maintain the layer order while also sorting instances inside layers? :)

  • @Zza804
    @Zza804 2 года назад

    Great tutorial, thanks a lot!

  • @malachishaner690
    @malachishaner690 6 месяцев назад

    I'm having major troubles drawing text while this depth sorter is active in the room. I tried all the obvious things and the only way I can get text to show up at all is by removing the depth sorter from the room. What am I doing wrong :(

  • @TeomanDeniz
    @TeomanDeniz 5 лет назад +1

    cutelest intro doesn't exi...

  • @drsquash2003
    @drsquash2003 4 года назад

    For static objects, couldnt you just have thier depth determined in the create event? And for dynamic objects, just have the depth update per frame at the end proir to the draw event?

  • @iKiwed
    @iKiwed 5 лет назад

    Great video

  • @hamzaaslam381
    @hamzaaslam381 2 года назад

    How i can make it consistent thoughout the rooms , i added it in the room start event but i think before that it has to clear the grid and thankyou for this helpful tutorial

  • @chadiel9152
    @chadiel9152 5 лет назад

    I like the new intro

  • @Musikur
    @Musikur 2 года назад

    Neat use of the map, although I would be a little concerned about performance if there are a LOT of objects in a room (you might need to have some kind of system to deallocate objects outside of the current view). I'm curious why you didn't use the traditional `depth = room_height - y;` though? For static objects this works really well as it is only called during the create event/

  • @gdomjan83
    @gdomjan83 5 лет назад

    Thank you for the great video. One think I wanted to ask if instead of putting event_perform (draw) into the final with statement, couldn't you just write visible = true? Because the way you turned off drawing was simply visible = false, so I thought turning it on is the opposite.

    • @FriendlyCosmonaut
      @FriendlyCosmonaut  5 лет назад +1

      The visible check itself won't make the instance draw in that moment in the order that we want. It just means that the next time the Draw pipeline is triggered and draws everything in the "incorrect" order, it will also draw the (now visible) instance. Hope that makes sense!

  • @makaiking0316
    @makaiking0316 3 года назад

    This is a great tutorial!

  • @yatta4339
    @yatta4339 2 года назад

    for whatever reason, theres one specific object that wont work with the depth system, so i always appear in front of it?

  • @NeZversSounds
    @NeZversSounds 5 лет назад

    Lovely intro!

  • @AaronAsherRandall
    @AaronAsherRandall 3 года назад

    What variable do we need to increment as we add new objects as children to the par_depthobject? Or can we leave the code as is? I am also confused on what order it is sorting in. How can I test this? Thank you!

  • @Cartoonicus
    @Cartoonicus Год назад

    Is it possible to change the layer depth with a function?

  • @rudy148
    @rudy148 4 года назад +3

    linda, maravilhosa, ótimo vídeo.

  • @roz9738
    @roz9738 11 месяцев назад +1

    Did anyone follow this tutorial and now their player character is flicking when facing a certain direction?

  • @AiguretDuren
    @AiguretDuren 3 года назад

    event_perform(ev_draw, 0) is 🔥🔥🔥

  • @DrJurdenPeterbergsteinlerwitz
    @DrJurdenPeterbergsteinlerwitz 2 года назад +1

    Did she ever make a vid where she includes tiles?

  • @rudy3376
    @rudy3376 3 года назад

    Make sure all your sprites in the depth system have the same origin for this to work properly.

  • @ariessuggs3819
    @ariessuggs3819 4 года назад

    I know this is an old vid but is there a reason why the draw gui event from other objects, that aren't involved with the depth system, no longer drawing anything?

  • @chris9085
    @chris9085 3 года назад

    so helpful! thank you!!

  • @luigisakeva
    @luigisakeva 3 года назад

    Depth Sorter:
    draw event : 9:39 - 23:41

  • @maxmi3091
    @maxmi3091 4 года назад

    In my game Armor and Weapons are drawn over the player sprite. Dependent of the current facing direction, the depth of the equipment is changing eg. looking left the shield is set to playerdepth - 1. Is there a way to change your code, so that it is working with my game? Nvm i found a easy solution:
    with(inst) {
    //event_perform(ev_draw,0);
    depth = yy*-100;
    }

  • @Waliente
    @Waliente 3 года назад

    Love your tutorial BUUUUUUUUUUUUUT i love so much your intro musiiiiic! :D

  • @ryarod
    @ryarod 3 года назад

    Hello.
    I have an issue. I've been following along, up to 17:57. When I attempt to run the program now, I get this error message:
    "In Object depth_sorter, in Event DrawEvent action number 1 at line 8 : Incorrect number of arguments for accessor
    Compile Failed - Please check the Compile window for any additional information."
    Would you know what might be causing this? I would welcome your recommendations as to what must be changed.

  • @bigdogsmallman
    @bigdogsmallman 4 года назад

    Great tutorial! I was wondering if this would also update on adding new instance layers? I'm trying to generate new instance layers but the depth system seems to not take them into account.

  • @chocobochick5390
    @chocobochick5390 5 лет назад +1

    I figured it out
    So for anyone who can see their character and their shadow but not like anything else (example: collision block, obj_tree, etc.) one of the problems is put depthsorter in the room. Don't put par_depthobject in the room, too, because it'll say something like, "par_depthobject has a Draw Event that says, 'Draw_self();' but it has no sprite to draw."
    So just make sure you put depthsorter in the room or you really won't be able to see anyone/anything else but your character and their shadow.

  • @MaxSkaw
    @MaxSkaw 5 лет назад +1

    Thank you for this tutorial, but if some instances that overlap each other are at the same y coordinate, they change which one is drawn first relative to where the player stands (Probably because when an instance changes its y coordinate and gets a higher or lower coordinate than another instance, it changes the draw order). I hope there is some kind of fix for this or else I think I can't use this method in my final game... :(

    • @Gnurklesquimp
      @Gnurklesquimp 4 года назад

      I was wondering what would happen if x axis is only difference, you ran into any simple and easy to apply fixes?

    • @roeyshapiro4878
      @roeyshapiro4878 4 года назад

      Doubt that it's still relevant, but you could:
      give instances an instance creation number that increments each time one is made (they're all already children of this draw object, so just make an inherited create event for them that increments some global "instance creation index" or something.) Then you can add a third column to the grid used to draw things and take that into account after having sorted by y-coordinate.

  • @cheque117
    @cheque117 4 года назад +1

    is there anyway to implement your depth system with a vertex_buffer. for example i'm using your depth system and also i followed GameMakerStation - Matharoo video:
    ruclips.net/video/MTdAdVt4EIM/видео.html
    to add grass as vertex buffers instead of objects but i cant seem to fuse the depth systems together, any thought?

    • @AaronAsherRandall
      @AaronAsherRandall 3 года назад +1

      I would like to know as well! Did you figure out a solution?

  • @chrishoyle27
    @chrishoyle27 5 лет назад

    Great video as always, and the new intro is kinda sweet.
    One critique if I may: you spend a good deal of time in this video going over data structures, data clean up and variable scope. This is fine of course, but you've covered this a number of times in previous videos, which means that you've already created some great resources to teach these important aspects. I would simply say don't be afraid to point people in the direction of these either in the description, through video annotations or even via your own in-video pop-ups.
    By doing this it will help keep the focus of the video on your intended topic, reduce run-time (which makes finding specific content easier when scrubbing the timeline), and, not to get all SEO on it, but re-linking back to your other videos increases the traffic to your channel, which helps you as a content creator.

    • @iKiwed
      @iKiwed 5 лет назад +1

      Chris Hoyle While I understand your point, I have to disagree for this specific video.
      It’s meant to be a remake of the video of a year ago, with a better application of the data structures. I think she made a wise choice, at least for novice programmers. But this is just my opinion.

    • @chrishoyle27
      @chrishoyle27 5 лет назад

      @@iKiwed I hear you, but re-make aside I would say that the concepts mentioned are quite fundamental, not only to GM, but most languages.
      Even if someone had only watched Cosmo's videos and no other GM-related content, a viewer should have still been exposed to these concepts unless it literally is the first time dipping their toe in.
      Beginner material is important for introducing and onboarding but obviously isn't needed in every situation. At a certain point it becomes beneficial to assume a level of proficiency. Providing links back to the existing library of content can help those with gaps in their knowledge.

    • @FriendlyCosmonaut
      @FriendlyCosmonaut  5 лет назад +1

      Thanks for the replies and I appreciate the critique! It's a conscious decision to make in every video, whether to explain some fundamental concepts or not. For some videos I do preface at the start that it's intermediate and I'm not going to be explaining X, Y, and Z. But that's usually when the concept itself is advanced and I can safely assume the people looking for that tutorial kinda know what they're getting into/are intermediate users already. But for something like this, a depth system can be something a beginner wants to put into their project at the start. It might very well be the first time they have ever used data structures, and indeed I received lots of comments like that in the last video. In the end I would rather explain too much and have someone be frustrated that they already understand it and skip forward, than have someone not understand something, and be unsure what to do (and perhaps not be able to proceed). I appreciate the suggestion to redirect people to other videos/documentation, but I know it's easier to digest when everything is explained within the context of what you're learning. Like, if you look up a word in a dictionary, but then the definition contains 3 more words you don't know and you have to go look them up - it's not a very useful definition. Plus I'm not too fussed about things like SEO/views, and I actually unlisted my old videos! I really just want to make content that's as clear as possible, which often does mean the videos run a bit longer.
      It would of course be better if I don't frustrate anyone - I do think it's a great idea to put some timestamps in, thank you Victoria - I forgot to do this!!

  • @massadlucas
    @massadlucas 4 года назад

    i did this to the pont you ran the game after you added the depthsorter to the room to see that all objects would be invisible.. the objplayer and the objmob didnt become invisible and after i deleted the parent depth and depthsorter my colisions disapeared and my mob stopped following me... whats going on???

  • @iand6309
    @iand6309 4 года назад +1

    Is there a way I can download the GMS2 project?

  • @fierorecensione5828
    @fierorecensione5828 11 месяцев назад

    top video!!!

  • @netowgtz
    @netowgtz 3 года назад +1

    when my sprites overlap, they start flickering :s

  • @KannanC1989
    @KannanC1989 4 года назад

    @firendlyCosmonaut is possible to get the source code for all you tutorial videos from Patreon ?

  • @saidnep_5433
    @saidnep_5433 5 лет назад

    Amazing

  • @deadpixstudios
    @deadpixstudios 5 лет назад

    like before watching 'coz I know it will be awesome

  • @王逸之-i7m
    @王逸之-i7m 3 года назад

    instances created via instance_create_layer doesn't seems to be controlled by this method, any idea how to sort those out?

    • @王逸之-i7m
      @王逸之-i7m 3 года назад

      my bad, wasn't adding event_inherited to child objects. Problem solved

  • @Spliffurt
    @Spliffurt 2 года назад +1

    i am dying slowly

  • @TheRealKaiProton
    @TheRealKaiProton 4 года назад

    just found this now, and Ive used your TUTS previously, always good, but with this one at first Debug run, Ive got an odd error, it says the first object in the list is not set,
    Variable objPlayer.dsDepth(100036, -2147483648) not set before reading it.
    at gml_Object_objSortOrder_Draw_0 (line 10) - dsDepth[# 0,i] = id;
    so dsDepth is my Grid name, and objSortOrder is your sorter object, I used i rather than yy as i it makes my mind see it better as index, either way, just a temp Variable,
    All Objects are on the Same Layer, also my grid doesnt even populate if I change it to a temp Variable name(dGrid) not sure why, Im on IDE 2.2.5.481, surely there isnt a code change in that version for this sort of thing.
    Also Ive deleted my Player object, and left the other ones, no matter what, this error pops up for the first id Add line, every time, I didnt see any additional items in the objects ??