GameMaker Studio 2 - The Basics of Collisions Beginner Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2025

ความคิดเห็น • 222

  • @AiguretDuren
    @AiguretDuren 4 ปีที่แล้ว +30

    Instant thumbs up because of the phrase "it is very janky movement and does not feel good to the player." That'll preach!

  • @drfunkmeetsnoise
    @drfunkmeetsnoise 7 ปีที่แล้ว +8

    your tutorials explain why you're coding that way so well. I find most tutorials to tell you what to do, but never explain why you're doing it. Thank you

  • @binghil5014
    @binghil5014 4 ปีที่แล้ว +5

    Your tutorials are the only ones i understand, even after 3 years (almost 4)

  • @omegathot5676
    @omegathot5676 3 ปีที่แล้ว +14

    thank you so much!! this is probably the only tutorial I've been able to memorize after only watching it ONCE. this helped so much! thank you!

  • @baldipogchamp8926
    @baldipogchamp8926 6 ปีที่แล้ว +4

    Been using GMS2 for a long time and I never really thought of using collisions this way!

  • @ilikeit2331
    @ilikeit2331 ปีที่แล้ว

    just saw your video, you helped me out on a 2 day struggle. I appreciate you so much.

  • @cocacolastic3963
    @cocacolastic3963 ปีที่แล้ว +1

    The best and the most helpful collision tutorial I've ever seen. Thank you!

  • @JonathanTash
    @JonathanTash 5 ปีที่แล้ว +6

    Thanks! I'm using a tile collision system, but your suggestion to check a bit ahead of where the player is moving fixed the spastic shaking when coming into contact with a wall.

  • @nightmarionnefury5516
    @nightmarionnefury5516 6 ปีที่แล้ว +3

    This made my object movement so much cleaner looking, thank you!

  • @Vrolenx
    @Vrolenx 7 ปีที่แล้ว +4

    Just wanted to stop by and say thank you so much for your tutorials they have helped a whole lot ! I will gladly support you on Patreon when i get a chance keep up the good work :D

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว +2

      +Vrolenx Thanks for saying so! I'm glad you're learning and enjoying the content.

  • @flatlander1690
    @flatlander1690 6 ปีที่แล้ว +14

    this video helped me out so much. you are a really great teacher wish you would do more of these thanks so much

  • @arvidinator3184
    @arvidinator3184 7 ปีที่แล้ว +7

    Really great tutorial! This works perfectly for GMS 1 too. Thanks man!

  • @NotMinute
    @NotMinute 7 ปีที่แล้ว +2

    Your tutorials are BEYOND helpful. Thank you so much.

  • @netowgtz
    @netowgtz 5 ปีที่แล้ว +4

    you are awesome, keep it up dude!

  • @WittAllen
    @WittAllen ปีที่แล้ว +1

    This was incredibly helpful. Thank you!

  • @ИмрПузя
    @ИмрПузя ปีที่แล้ว +1

    Спасибо! Вы не представляете сколько я времени потратил на это. Оказалось что всё решение в одной кнопочке!

  • @jamesanthonymaguirechannel
    @jamesanthonymaguirechannel 7 ปีที่แล้ว +3

    you are a legend at teaching now you have 1 more subscriber :] thanks

  • @nonameinc202
    @nonameinc202 7 ปีที่แล้ว +4

    Dude, you are my hero!! Also, can you make an tutorial how to make dialogue system in GMS 2?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว +2

      Thanks! And that is something that I've got in my list for a little while down the road. So keep your eye out for it.

  • @billypearson8661
    @billypearson8661 ปีที่แล้ว

    To avoid having to make either object solid, could you replace place_free with place_meeting?

  • @kisforkazoo8183
    @kisforkazoo8183 3 ปีที่แล้ว +1

    Dude this helped a lot thanks

  • @xcalicojack
    @xcalicojack 10 หลายเดือนก่อน

    How do you walk behind a wall without turning the wall into an object? The walls are usually part of tilesets and I can't get this to work, even if I set the wall tileset to a higher layer above the player instance.

  • @Reqcore
    @Reqcore 2 ปีที่แล้ว +1

    Something really strange is happening to my collision. It works fins if the collision box is approached from the left, right and up, but if I go down I can go right through it. Some distance away to the upper left however I can run into the collision to go down but its not where its supposed to be. I have no idea what to do about this.
    EDIT: Solved, My collision mask on the sprite was positioned way off center. Thank you for the video, super helpful!

  • @troyglover79
    @troyglover79 4 ปีที่แล้ว +1

    You are awesome!!! This is a really great video. Thank you very much.

  • @littlebudddy
    @littlebudddy 2 ปีที่แล้ว

    how did you do that thing to drag the brick wall around?

  • @kevinlong5104
    @kevinlong5104 4 ปีที่แล้ว +2

    I don't know why. I entered the exact same place_free codes with yours into my program and checked that all the walls and my player character are solid. However this is not working, the player character still runs through the wall regardless. Please help, Thank you!

  • @echorinP
    @echorinP 3 ปีที่แล้ว

    will you ever do a tutorial covering depth?

  • @ZoobTubed
    @ZoobTubed 6 ปีที่แล้ว +1

    You are my fucking savior i spent a hole weekend trying to do this thank you so much
    :D

  • @nyongatienza820
    @nyongatienza820 7 ปีที่แล้ว +1

    I need your help!
    I got the same problem in the part of your video at 3:40 but then i write the code and it gets vice versa. I can now move it when it sticks the collision(just like in your video) but now after i write your code, if the character is walking next to the collision and i am going to make the character face the collision its not working and it keeps on walking on the direction that i click. Is it possible that i can make it face the collision even if i keep on clicking the left or right arrow (under the collisio). Thanks a lot i hope you'll answer my question. Btw here's my code. but i guest there's nothing wrong on it.
    if(keyboard_check(vk_right) and place_free(x + collisionSpeed, y)) {
    x+= walkSpeed;
    image_speed = walkSpeed / 3;
    sprite_index = sprA_walkright1;
    }
    if(keyboard_check(vk_left) and place_free(x - collisionSpeed, y)) {
    x-= walkSpeed;
    image_speed = walkSpeed / 3;
    sprite_index = sprA_walkleft1;
    }
    if(keyboard_check(vk_up) and place_free(x, y - collisionSpeed)) {
    y-= walkSpeed;
    image_speed = walkSpeed / 3;
    sprite_index = sprA_walkup1;
    }
    if(keyboard_check(vk_down) and place_free(x, y + collisionSpeed)) {
    y+= walkSpeed;
    image_speed = walkSpeed / 3;
    sprite_index = sprA_walkdown1;
    }
    Thankyou very much!

  • @vtotolhua
    @vtotolhua 7 ปีที่แล้ว +3

    Great Tutorial, helped me a lot, avoided the work to create an event for every object.!! Thanks!!

  • @AlexhubbardSoulboundGaming
    @AlexhubbardSoulboundGaming 2 ปีที่แล้ว

    Hey man! So, I'm having an issue. while the collision is working, when I try and face up towards my x axis wall while facing left or right, he doesn't face it and stays left or right. Same with y axis wall, he will be facing up and down, but can't turn towards the wall. Also, if I move to the right or left flush to the wall and let go and just hold up. The animation for walk left or walk right plays continuously.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  2 ปีที่แล้ว +1

      Check that your collision mask isn’t changing if you’re changing sprites as you move around. That can cause all sorts of issues. Set your collsion mask to just 1 sprite.

    • @AlexhubbardSoulboundGaming
      @AlexhubbardSoulboundGaming 2 ปีที่แล้ว

      @@LetsLearnThisTogether I will check that, thank man !

  • @SincerelyTaterTot
    @SincerelyTaterTot ปีที่แล้ว +1

    For some reason I still end up getting stuck, once my character interacts with it, If I press any button, it gets stuck.

  • @enzogray1073
    @enzogray1073 6 ปีที่แล้ว +1

    This helped a lot, thanks.

  • @arcjerzfordayz
    @arcjerzfordayz 11 หลายเดือนก่อน

    my collision fade aint collision fading... how can i fix that?

  • @Take2x2
    @Take2x2 5 ปีที่แล้ว +1

    I did the same code but I can't even move. Help.

  • @langtuyetvuanh1999
    @langtuyetvuanh1999 6 ปีที่แล้ว +1

    Can anyone help me. I coded exactly what he coded on video. But I still got stuck when move right or left over the wall. There was no problem with moving up and down. :(.

  • @bryansanyoto8305
    @bryansanyoto8305 6 ปีที่แล้ว +1

    thank you so much, this helped me so much

  • @ВладМирошниченко-л2и
    @ВладМирошниченко-л2и 7 ปีที่แล้ว +30

    I think i will stick to you and Heartbeast as my main gamemaker masters =D

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว +2

      +Влад Мирошниченко That means a lot, thanks!

    • @legsofjelly4428
      @legsofjelly4428 7 ปีที่แล้ว +2

      +Влад Мирошниченко And look a Tom Francis. He has many tutorials, goes at a good slow pace, and made 2 games on steam, Gunpoint and Heat Signature.

    • @arvidinator3184
      @arvidinator3184 7 ปีที่แล้ว +4

      Shaun Spalding is also a fantastic teacher. He usually explains how to perform a multitude of actions using code.

    • @seanguides8847
      @seanguides8847 4 ปีที่แล้ว +1

      @@legsofjelly4428 i love those games
      boutta check him out

  • @omaghphil
    @omaghphil 6 ปีที่แล้ว

    on ghost walls etc and if u have a character walking up to an object that has a collision mask set higher so the character overlaps the bottom end how do u make the character appear above the object and not below it? is it also possible to make the object overlap the character while the character is at the top end and the character overlap it while at the bottom end? Hope this makes sense

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      You're talking about depth. This is something you can set anytime, and the lower the depth, the closer to the screen it is.
      So if you want the character on top of a box, make the characters depth 0, and the boxes 10.

  • @ameno714
    @ameno714 6 ปีที่แล้ว

    Hey, I'm using Game Maker 8 for a school project to make a game. Your code helped me out big time. Now for the problem I'm having;
    I use 8 directional movement with my character, to get this collision working I removed my old code and copied yours. With my old code the character would always walk the same speed (when walking left 3.5 spd and when walking up-left 3.5). But now I have double the speed when walking using for example W and D.
    I you could help me out I'd really appreciate it. Thanks!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      Hey.
      So what you’ll need to do is check when holding down more than 1 key and then adjust the speed of the player accordingly. You can do that with an if statement, checking the combination of keys you have.

    • @ameno714
      @ameno714 6 ปีที่แล้ว

      @@LetsLearnThisTogether Thanks for reacting! I tried that in between my comment and your reaction, but I have the problem of the speed doubling up:
      I have seperate if statements for W, D and W+D for example. When I press W+D it changes both x and y by an amount, but then it also checks the seperate ones for W and D and adds all those up.
      Do you know how to fix this?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      For those separate comments, make the speed slower. Set speed to about half, and that will solve it for ya.

    • @ameno714
      @ameno714 6 ปีที่แล้ว

      @@LetsLearnThisTogether Big thanks mate!

  • @aper765
    @aper765 2 ปีที่แล้ว

    thanks sooo much

  • @s4mm4st3r5
    @s4mm4st3r5 7 ปีที่แล้ว +1

    Good stuff mate.

  • @imnotme2681
    @imnotme2681 6 หลายเดือนก่อน

    This didn't work for me, what do you think could have gone wrong cuz I followed your code exactly even try fiddling with the collisions in that didn't work either

  • @ThyCrowing
    @ThyCrowing 3 ปีที่แล้ว

    Unfortunately, I can't manage to make the tree go transparent as I walk behind it, no matter how many times I try to rewrite the code.

  • @electricanimations6183
    @electricanimations6183 5 ปีที่แล้ว

    Okay so, if i start a project up thats gml and just put a collision with the wall and the player, the player stops like it should, but if it's dnd (which is the one im using) it doesnt stop the player. Does it only work on gml?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 ปีที่แล้ว +1

      I don’t use DND much. All I can say is that I’ve had a lot of trouble trying to get some of my code converted to DnD, so I wouldn’t be surprised if there was something wrong with it.

    • @electricanimations6183
      @electricanimations6183 3 ปีที่แล้ว +2

      @@LetsLearnThisTogether Bro i finally fixed it

  • @MaxHasManyHobbies
    @MaxHasManyHobbies 4 ปีที่แล้ว

    What happened to your advanced course? Udemy says that it's not available any longer. Where is it now?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 ปีที่แล้ว +1

      It’s on my website. I’m keeping beginner stuff on Udemy, but moving everything else to my site, letslearnthistogether.com
      My new advanced course is also available there, and you can buy them as a bundle. If you’ve already purchased my beginner course, send me an email with proof and I’ll give you a discount for the bundle.

  • @trove-g6676
    @trove-g6676 6 ปีที่แล้ว +9

    i know that im over a year late, but please respond, i converted my gamemaker 1.4 project (with working collisions, the same shown here in fact) to game maker studio 2. Now, none of the collisions work, and i even deleted every collision event and re-did them, but they still wont work. is there some sort of setting in gms2 that i need to enable or what

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว +4

      No setting, and it’s odd that it doesn’t work. Check that each object is still ticked to solid.
      If that doesn’t work, send the project over to me at beyondusgames@gmail.com. Be sure to send the entire project, not just one file. You can zip it up, or export it from within GMS.

    • @lyrimetacurl0
      @lyrimetacurl0 6 ปีที่แล้ว

      I found it ignores solid collisions unless something happens in the collision event (even if it's just a bump sound, anything makes it work). I dunno what causes this, seems like a bug.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว +1

      As long as there’s anything in the collision event it will trigger, but if it’s empty then nothing happens.

  • @brendahodgkins603
    @brendahodgkins603 4 ปีที่แล้ว

    I'm trying to make a game where my ball bounces off the walls (kinda like brickbreaker) but the ball goes through the wall and out of sight. Can you help please? My wall is solid

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 ปีที่แล้ว

      There are a couple of ways to handle this. The easiest one is to remove the solid walls and use the event, Intersect Boundary (under Other). It will trigger when an object comes to an edge of your room, and then you can just pick a new direction for it to go in.
      There's also a function to make objects bounce off other solids, which could work. It's called move_bounce_solid, or move_bounce_all

  • @tiagoorevoltado2273
    @tiagoorevoltado2273 5 ปีที่แล้ว

    h thanks to teach us how use the game maker. I liked ask if is possible. well first I like tell my history. I create a NPC and a path to her and I create a caracter male (this caracter I use button), but when I touch the NPC he's stuck. can you help how resolve this trouble? thanks.

  • @bubblemage
    @bubblemage 6 ปีที่แล้ว

    This is pretty late but how do I make it so I can collide with DIFFERENT objects? Do I have to copy and paste the collision part for aaaaall the rest of objects?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      Parent objects are probably what you’ll want to use. Make one parent and then all their children can be checked to collide with by just checking collisions with the parent.

  • @william1026
    @william1026 4 ปีที่แล้ว

    Im like getting tp'd one pixel to the left and up and them in stuck inside of the wall

    • @william1026
      @william1026 4 ปีที่แล้ว

      update - fixed it

  • @LoopyYTOfficial
    @LoopyYTOfficial 4 ปีที่แล้ว +1

    7:00 Who fought and died for yer wee bit hill & glen!

  • @LiamADHD
    @LiamADHD 2 ปีที่แล้ว

    OK, it works for me but the object only goes in to alpha .25 when im in the top left of it, otherwise nothing,

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  2 ปีที่แล้ว +1

      Check your collision boxes and origins on your sprites. Sounds like they’re set to top left, and middle center might be better.

    • @LiamADHD
      @LiamADHD 2 ปีที่แล้ว +1

      @@LetsLearnThisTogether I do the collision mask as custom and do it myself so that's all ok but origins I'll have to look at. Only been doing it two days. It's hard but once u know it u never forget and this skill is worth alot to some people thanks mate

  • @egosactorco
    @egosactorco 7 ปีที่แล้ว

    Hey so the sprite im using has a walk cycle where it bobs up and down to make it look like hes actually walking, with that the row of pixels that while standing on the ground dont touch the block will then pop into it and then my sprite will get stuck, do you know how i can fix this?

  • @calebj6389
    @calebj6389 5 ปีที่แล้ว

    I'm currently having 2 problems. First one is where if I'm holding down, my character can move straight through the objects. And the second one is if I hold right, my character stops about Midway through the screen and can't continue even though there isn't anything there. Any ideas on what may be wrong?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 ปีที่แล้ว

      Sounds like where you're checking your collisions might be in the wrong place. Ensure your code is in the same order as I've put there.

  • @veng3r663
    @veng3r663 6 ปีที่แล้ว

    Can we import and or make new sound files in here ? I'm REALLY hoping I can use this to recreate Phatasie once more....

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      You can’t create new sound files in GMS, but you can import any you like as long as they’re the right file type.

    • @veng3r663
      @veng3r663 6 ปีที่แล้ว +1

      @@LetsLearnThisTogether Cool thanks for the reply. Hoping to imitate a lot of that game's unique sounds which made its combats so memorable & enjoyable... :)

  • @lad4497
    @lad4497 6 ปีที่แล้ว

    Great tutorial, but one problem I'm having.
    It works up until the point where I make my player go into a corner of a block and it goes through and gets stuck. How might I fix this?
    *EDIT*
    Turns out it indeed does not go into the corners, but the top in general, and it can only go left and right once it hits the bottom.

  • @adamrobertc
    @adamrobertc 4 ปีที่แล้ว

    Do you have any idea why it might have the collision only stick when I'm going to the left?
    This is what my collision code looks like:
    if(keyboard_check(vk_left) && place_free(x - collisionSpeed, y))
    {
    x -= walkSpeed;
    image_speed = walkSpeed/3;
    sprite_index = spr_SaraWalkLeft;
    }

  • @armiefalconi5947
    @armiefalconi5947 6 ปีที่แล้ว

    wait do i have to do all that other code too?

  • @gottafindacoolname
    @gottafindacoolname 3 ปีที่แล้ว

    how do you change the empty tile to a different tile??? pleeeeeeeeease help me im going insane!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 ปีที่แล้ว

      Can you be more clear? Are you using tile sets and want to change an empty tile to another tile in that set?

    • @gottafindacoolname
      @gottafindacoolname 3 ปีที่แล้ว

      @@LetsLearnThisTogether yes i suppose. Beacuase often you download a tileset and you need the first tile, but Gamemake makes it empty by default. This is super annoying. I would rather have it be the last fx? or a tile of my choosing. :)

  • @emilep.3803
    @emilep.3803 5 ปีที่แล้ว

    It really helped me with my main character, but what do we do with AI ??? Help please !

  • @emilkummerfeldt9836
    @emilkummerfeldt9836 3 ปีที่แล้ว

    when i walk into a wall i can only move up and down in my game. but that's only if i face to the right, if i face to the left i can't move. please help me someone i beg you!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 ปีที่แล้ว

      Can you share a link to your project or a screenshot of your code or just your code? I can't do much without more info.

    • @emilkummerfeldt9836
      @emilkummerfeldt9836 3 ปีที่แล้ว

      @@LetsLearnThisTogether it's allright now. i found out what the reason for this was

    • @mahibfazley7486
      @mahibfazley7486 2 ปีที่แล้ว

      @@emilkummerfeldt9836 what was the reason because the same thing is happening to me?

  • @StormyDoesVR
    @StormyDoesVR 7 ปีที่แล้ว

    Alrighty, so most of the time this is working for me, but if I try and move in enough direction while still next to the wall the sprite will intersect the block, get stuck, and stops moving/animating at all. Any ideas? (btw, tysm you're a huge help!)

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว +1

      +Art Inferno Yeah, that's a problem with this system. I've got a fix coming soon. In the meantime, look at heartbeats platformer movement for a pretty good system, if you can follow.

    • @StormyDoesVR
      @StormyDoesVR 7 ปีที่แล้ว +1

      Thanks for getting back to me! Can't wait for your fix! Thx!

    • @henrydickenson4125
      @henrydickenson4125 2 ปีที่แล้ว

      @@LetsLearnThisTogether How did you get on with this solution? ;)

  • @Zeldafan-cb8zr
    @Zeldafan-cb8zr 3 ปีที่แล้ว

    Please help me: it freezes my character whenever I go up or down.

  • @matthewscriven3840
    @matthewscriven3840 7 ปีที่แล้ว

    so i listed both objects as" solid" but there still just passing through each other :I is there any reason for this?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว +1

      +Matthew Scriven Two "solid" objects can still pass through each other. The solid marking is for when using certain functions, which check against solid or non solid objects.
      So to make things run into each other, use the Collison event or some of the functions we use in the video.

    • @matthewscriven3840
      @matthewscriven3840 7 ปีที่แล้ว

      Thanks my dude :D

    • @lyrimetacurl0
      @lyrimetacurl0 6 ปีที่แล้ว

      @@LetsLearnThisTogether Mine still went through each other, but I figured out a glitch because setting the collision to change sprite as the event and that originally caused it to act solid, which I thought was strange. Maybe it's a result of using drag n drop actually. Though I personally think DND is easier because I could move "set sprite" before the if statement (check if free) just by dragging and dropping. I would take ages to code that if the if statement was overarching (in DND there are separate if statements for each direction).
      I tested this further by having nothing but playing a sound in the collision event, and then the objects acted solid. Without the sound, they passed through. On the plus side, I have now set it to display the resting sprites (so they don't stop mid-walk) except that they don't actually collide so it's useless code... ).

  • @Spyder177
    @Spyder177 7 ปีที่แล้ว

    What about with gravity. My game character never gets stuck when i move him around without gravity but when i turn gravity on like i want in my game he gets stuck when he hits the ground then dis appears

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Spyder177 Gravity/physics is a whole other beast, that can get very complicated. I'm not too familiar with it. You'll need to use the physics function for collisions, and that's not really what this is covering.

    • @Spyder177
      @Spyder177 7 ปีที่แล้ว

      Alright thank you anyway

  • @sugarandbones6272
    @sugarandbones6272 5 ปีที่แล้ว

    help?
    my collisions aren't exact
    the objects always have a lot of distance between them though i have collision speed + 1

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 ปีที่แล้ว

      Definitely check out heart beasts collision platformer videos, as this one is very old and really not a good idea. I need to take it down.

  • @eternalwarfare514
    @eternalwarfare514 4 ปีที่แล้ว

    After I added the place_free functions into the controls, for some reason the player character doesn't move at all anymore. What might've gone wrong?
    The code looks exactly the same too:
    if keyboard_check(ord("W") && place_free(x, y - collision_speed)){
    y -= moving_speed;
    }
    if keyboard_check(ord("A") && place_free(x - collision_speed, y)){
    x -= moving_speed;
    }
    if keyboard_check(ord("S") && place_free(x, y + collision_speed)){
    y += moving_speed;
    }
    if keyboard_check(ord("D") && place_free(x + collision_speed, y)){
    x += moving_speed;
    }

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 ปีที่แล้ว

      My guess is you've got something, like a big object, that's registering as not free around the player. Check your instances in the game, and see what else there is there. If nothing, then what's your collision speed at? It may be finding your own character, if your speed is really low.

    • @eternalwarfare514
      @eternalwarfare514 4 ปีที่แล้ว

      @@LetsLearnThisTogether The character speed is set at 5 by me, and the collision speed, following your formula, is at 7.

    • @eternalwarfare514
      @eternalwarfare514 4 ปีที่แล้ว

      @@LetsLearnThisTogether Is there anything wrong with the collision speed I have?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 ปีที่แล้ว

      It doesn’t look like the code you posted is wrong. My guess is it’s something else in your project.

    • @eternalwarfare514
      @eternalwarfare514 4 ปีที่แล้ว

      @@LetsLearnThisTogether Well, aside from the solid walls, I have another type of 'sludge' which slows down the player when it's in it. Perhaps, do I need to specify which type of wall the player is being collided with?

  • @KzmGaming
    @KzmGaming 6 ปีที่แล้ว

    Brother why can't export my game I pay the license i have problems when I created keystone its says something about keytool command any one can help please

  • @ChaneyChonga
    @ChaneyChonga 5 ปีที่แล้ว

    I know I'm posting this really late, relative to the video, but how come my sprite doesnt work for the simple collisions
    and I copied down the same exact code word for word? Has something changed since gm2 2017 and gm2 2019?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 ปีที่แล้ว

      No, nothing's changed. Is it in the step event? Do you have a good sized bounding box for your Sprite?

    • @ChaneyChonga
      @ChaneyChonga 5 ปีที่แล้ว +1

      @@LetsLearnThisTogether Haha I've been fiddling around with the code and I've gotten it to work now using what you've had in the video. Thanks for trying to help me out though. :D There seemed to be a problem between the size of my sprite and box, I just made the box the same size as my sprite and it worked.

  • @jbxfox2280
    @jbxfox2280 6 ปีที่แล้ว

    can we save the game as ordinary game .exe file...which can be run in any pc?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      Indeed. Under the build menu, you can do it there.

    • @jbxfox2280
      @jbxfox2280 6 ปีที่แล้ว

      Beyond Us Games how?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      In the top right corner you choose your platform. Set it to windows. Then under build near the top middle, choose the option to create executable (I believe that's what it is. It's one of those options.)

    • @jbxfox2280
      @jbxfox2280 6 ปีที่แล้ว

      Beyond Us Games thank you brother

  • @sk7811
    @sk7811 5 ปีที่แล้ว

    I keep getting the error “unassigned variable collisionSpeed referenced”. How do I fix this?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 ปีที่แล้ว +1

      If a variable is unassigned you haven't given it a value before trying to access it. Usually caused by an misspelling. Double check your variables.

    • @sk7811
      @sk7811 5 ปีที่แล้ว

      Beyond Us Games You were right, the variable was named “collsionSpeed”. Lol. It all works now. Thanks for the quick response.

  • @test-bh9su
    @test-bh9su 7 ปีที่แล้ว

    please help!
    what does this mean?
    FATAL ERROR in
    action number 1
    of Step Event0
    for object obj_character:
    Variable obj_character.collisionSpeed(100007, -2147483648) not set before reading it.
    at gml_Object_obj_character_Step_0 (line 21) - if(keyboard_check(ord("W")) && place_free(y, x+ collisionSpeed)

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Vegan Beast Hunter It means the variable collisionSpeed hasn't been given a value when you're trying to use on line 21. Check your create event, be sure it's spelled exactly the same, that's usually where the error lies.

    • @test-bh9su
      @test-bh9su 7 ปีที่แล้ว

      this is my create event:
      //Collision
      image_speed = 0;
      walkSpeed = 3.5;
      collisonSpeed = walkSpeed + 2;

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Vegan Beast Hunter Yeah, I can see the problem. It's a tiny spelling error, you're missing the i in collision when you create that variable.

    • @test-bh9su
      @test-bh9su 7 ปีที่แล้ว +1

      Wow, sorry I had to bother you :D
      Thanks man!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Vegan Beast Hunter It happens to the best of us.

  • @torsten2705
    @torsten2705 7 ปีที่แล้ว

    I don’t know if I’m just stupid or it’s just the program but when i create a collision event on my player object it says error: object uses sprite wall which is not being exported HELPPPP

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Torsten Klein I've never seen that kind of message before, so it sounds like it's the program. Try deleting that sprite and reimporting it.

    • @torsten2705
      @torsten2705 7 ปีที่แล้ว

      Beyond Us Games thanks. Im definitely gonna try that!

  • @monarchvlinder
    @monarchvlinder 5 ปีที่แล้ว

    when the player walks up or down into the wall, it works perfectly. but when the player walks left or right into the wall, it goes halfway through the wall and gets stuck. help?

    • @aaron4227
      @aaron4227 4 ปีที่แล้ว

      I think it's to do with your sprite, go on it and see if the little + is in the middle (sorry I haven't used gml in a while I forgot the specific names).

  • @kagethewolf3954
    @kagethewolf3954 7 ปีที่แล้ว

    after i added the wall "sara" is leaving after immages of her behing where she walks

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +WOLF MUSIC After images? That's.. Unusual. You can export your project and send it to me at beyondusgames@gmail.com, where I'll take a look at it and get back to you. I always enjoy finding new bugs.

    • @kagethewolf3954
      @kagethewolf3954 7 ปีที่แล้ว

      how do i export it

    • @kagethewolf3954
      @kagethewolf3954 7 ปีที่แล้ว

      it sent tell me if there was an issue

  • @earthwormdew9535
    @earthwormdew9535 4 ปีที่แล้ว

    When I add gravity(im doing a 2d platformer) collision does not happen why is this.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 ปีที่แล้ว

      I don't know, how are you implementing the gravity?

    • @viniciuscutolo5567
      @viniciuscutolo5567 3 ปีที่แล้ว

      just make the gravity deactivate when you touch something, like: if (place_free(x, y + ColisionSpeed)){ gravity = 0{else} gravity = 10{

  • @bigmancozmo
    @bigmancozmo 3 ปีที่แล้ว

    pls help my character is still getting stuck in every place except when he goes down

  • @gatarsystem
    @gatarsystem 4 ปีที่แล้ว

    Doesn't work,
    my object still goes right through.
    Create:
    hspd = 5;
    colisspd = hspd + 2;
    Step:
    if (keyboard_check(ord("A")) && place_free(x - colisspd,y)){
    x -= hspd;
    }

    if (keyboard_check(ord("D"))&& place_free(x + colisspd,y)){
    x += hspd;
    }

  • @remdem622
    @remdem622 7 ปีที่แล้ว

    hey beyond us games, i have just found your youtube channel and this was what i was looking for but i'm having trouble, i can move fine and my player does not get stuck in objects but every time it has a collision with another object, it keeps playing the sprite_index over and over again, here is my code:
    //for movements and collisions
    //for the player to move right
    if(keyboard_check(vk_right)and place_free(x + collisionspeed, y)) { //vk_right meaning right arrow key
    x += walkspeed;//x += walkspeed for right and x-= walkspeed for left
    image_speed = walkspeed / 3;//sets the image_speed to the x + walkspeed / 3
    sprite_index = spr_youwalkingright;//sets sprite index = to you walking right when you hit right arrow
    }//end of code for (moving right)
    //for the player to move left
    if(keyboard_check(vk_left)and place_free(x - collisionspeed, y)) {
    x -= walkspeed;//the oppisite for walking right
    image_speed = walkspeed / 3;//sets the image_speed to the oppisite of moving left instead of x += walkspeed its x -= walkspeed
    sprite_index = spr_youwalkingleft;//sprite_index sets when this key is pressed play this animation
    }//end of code for (moving left)
    //for the player to move up
    /*note: for setting the up arrow the y needs to be the oppisite of x, example:
    for moving up (this code) you need y -= walkspeed and for moving down it would be y += walkspeed
    */
    if(keyboard_check(vk_up)and place_free(x,y - collisionspeed)) {
    y -= walkspeed;//like in the notes, make your next one y += walkspeed
    image_speed = walkspeed / 3;//sets the image_speed to be y -= walkspeed / 3
    sprite_index = spr_youwalkingup;//sets sprite animation to be you walking up
    }//end of code
    //for player to move down
    if(keyboard_check(vk_down)and place_free(x,y + collisionspeed)) {
    y += walkspeed;//this y -= walkspeed is the oppisite of the moving up code
    image_speed = walkspeed / 3;//sets image_speed to be y += walkspeed / 3
    sprite_index = spr_youwalkingdown;//sets sprite animation to you walking down
    }//end of code
    //to stop the sprite_index to go forever
    //for when the player realese's the right arrow
    if(keyboard_check_released(vk_right)and place_free(x + collisionspeed,y)) {
    image_speed = 0;
    sprite_index = spr_youstandingstillright;/*this line of code is saying that when this key is realesed,
    set sprite_index to be you standing still to the right
    */
    }//end of code
    //for when the player realese's the left arrow
    if(keyboard_check_released(vk_left)and place_free(x - collisionspeed, y)) {
    image_speed = 0;
    sprite_index = spr_youstandingstillleft;/*this line of code is saying that when this key is realesed,
    set sprite_index to be you standing still to the left
    */
    }//end of code
    //for when player realese's the up arrow
    if(keyboard_check_released(vk_up)and place_free(x, y - collisionspeed)) {
    image_speed = 0;
    sprite_index = spr_youstandingstillup;/*this line of code is saying that when this key is realesed,
    set sprite_index to be you standing still facing up
    */
    }//end of code
    //for when the player realese's the down arrow
    if(keyboard_check_released(vk_down)and place_free (x,y + collisionspeed)) {
    image_speed = 0;
    sprite_index = spr_youstandingstilldown;/*this line of code is saying that when this key is realesed,
    set sprite_index to be you standing still facing down
    */
    }//end of code
    know how to fix it? thanks!

    • @remdem622
      @remdem622 7 ปีที่แล้ว

      p.s
      sorry if there are to many comments!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Ezra Holladay It looks to me like you don't need the and check on the release keys, as you're telling it to only stop animating if it isn't colliding. You want it to stop animating even if it is colliding.

    • @remdem622
      @remdem622 7 ปีที่แล้ว +1

      it worked! thank you so much

    • @remdem622
      @remdem622 7 ปีที่แล้ว +1

      just subscribed!
      your amazing!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Ezra Holladay Aw shucks. Thanks.

  • @salihbaserofficial
    @salihbaserofficial 7 ปีที่แล้ว

    Can you put lesson files here please ?

  • @quismu
    @quismu 7 ปีที่แล้ว

    My smooth collision works only on the up and down sides of my brick object.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว

      +Kuisma Kaikkonen Double check you've got the + and - on the correct if statements. If you're add your collision speed when moving left, it won't work.

    • @quismu
      @quismu 7 ปีที่แล้ว

      Beyond Us Games Oh! Now it works. Thank you!

  • @Mackievellian
    @Mackievellian 4 ปีที่แล้ว

    I have an issue with the animation, actually! If I collide with a wall now, and I hold left after holding up, I'll be stuck to the object and the animation will continue playing for walking left, so, it looks like my character is walking in place. I watched to the end, also. I'm not sure what's wrong.
    Cheers though.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 ปีที่แล้ว +1

      If you’re using sprites with different sized images for walking/running or anything like that, it’s tough. You’ve got to manually adjust the origin on each sprite for your player so they all “match” when moving around. Otherwise when you change to left or right, you could clip into a wall.
      I’ve also got a video about getting unstuck when something like that happens.

    • @dotdot5906
      @dotdot5906 2 ปีที่แล้ว

      @@LetsLearnThisTogether I've got another issue. For some reason if you collide corner to corner with your player object and the collision object you will get stuck. Meaning if you just run around the square it will eventually happen. How come?

  • @juliuscarlnavales8432
    @juliuscarlnavales8432 7 ปีที่แล้ว

    Were can u get ur pixel art?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  7 ปีที่แล้ว +1

      +EXPLODE GAMING Sara is from Open Game Art. Search that and you'll find her. I'm not sure about the rest. Probably on there too.

  • @sk7811
    @sk7811 5 ปีที่แล้ว

    Sorry to bother, but do you by any chance know how to fix something when my character runs into a wall and is stuck completely?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 ปีที่แล้ว +1

      Yeah, look around my videos. There's a video I've got about getting unstuck.

    • @Zeldafan-cb8zr
      @Zeldafan-cb8zr 3 ปีที่แล้ว

      @@LetsLearnThisTogether where is the video?

  • @kassburn1028
    @kassburn1028 6 ปีที่แล้ว

    The trick with the tree didn't work for me, I try to write the code 3 times >

  • @CrazyKiwiGaming
    @CrazyKiwiGaming 6 ปีที่แล้ว

    question: where is 720P/60 resolution?

  • @TranQBaocuto601
    @TranQBaocuto601 2 ปีที่แล้ว

    help me pls my character is stuck every where its cant move

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  2 ปีที่แล้ว

      I can help if you share more details and the code you think is causing the issue

  • @objectlore
    @objectlore ปีที่แล้ว

    If youre still around, can i have the script?

  • @adamaouladdyalabok
    @adamaouladdyalabok ปีที่แล้ว

    but my character uses the mouse pointer to move

  • @sambam3289
    @sambam3289 6 ปีที่แล้ว

    Big message, sorry :(
    Hey so i'm trying to get this to work, i'm fairly new with GML but could someone tell me what is wrong with this code? Also this is the crash report that i get, "FATAL ERROR in
    action number 1
    of Step Event0
    for object obj_player:
    keyboard_check_released argument 1 incorrect type (string) expecting a Number (YYGI32)
    at gml_Object_obj_player_Step_0 (line 26) - if(keyboard_check_released("D")) { //Sets the sprite to stand still in current direction
    "
    stack frame is
    gml_Object_obj_player_Step_0 (line 26)
    CODE:
    // @description Player Movement
    if(keyboard_check_pressed(ord("D")) && place_free(x + collisionspeed, y)) { //Move to the right
    x += walkspeed; //physically moves the object the amount of walkspeed to the right
    image_speed = walkSpeed / 3; //plays the current sprite's animation
    sprite_index = spr_player_right; //assigns sprite to object when key D is pressed
    }
    if(keyboard_check_pressed(ord("A")) && place_free(x - collisionspeed, y)) { //Move to the left
    x -= walkSpeed /
    image_speed = walkSpeed / 3;
    sprite_index = spr_player_left;
    }
    if(keyboard_check_pressed(ord("W")) && place_free(x, y - collisionspeed)) { //Move up
    y -= walkSpeed /
    image_speed = walkSpeed / 3;
    sprite_index = spr_player_up;
    }
    if(keyboard_check_pressed(ord("S")) and place_free(x, y + collisionspeed)) { //Move down
    x += walkSpeed /
    image_speed = walkSpeed / 3;
    sprite_index = spr_player_down;
    }
    if(keyboard_check_released("D")) { //Sets the sprite to stand still in current direction
    sprite_index = spr_player_still_right;
    image_speed = walkSpeed / 0;
    }
    if(keyboard_check_released("A")) { //Sets the sprite to stand still in current direction
    sprite_index = spr_player_still_left;
    image_speed = walkSpeed / 0;
    }
    if(keyboard_check_released("W")) { //Sets the sprite to stand still in current direction
    sprite_index = spr_player_still_up;
    image_speed = walkSpeed / 0;
    }
    if(keyboard_check_released("S")) { //Sets the sprite to stand still in current direction
    sprite_index = spr_player_still_down;
    image_speed = walkSpeed / 0;
    }

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      When checking letters you have to put them with function ord like this:
      Keyboard_check_released(ord(“D”))

  • @grantdavis5438
    @grantdavis5438 5 ปีที่แล้ว +4

    uhh… I made a new object, made both the player object and the new object solid, and created a collision event and it didn't work

  • @seanguides8847
    @seanguides8847 4 ปีที่แล้ว

    wierdly it works horizontally but not vertically

  • @awesomedude4650
    @awesomedude4650 5 ปีที่แล้ว

    How do you place a line of blocks instead of just placing them one by one? I know it might sound simple but I’m just getting into this stuff.

  • @Jace-_
    @Jace-_ 7 ปีที่แล้ว

    In my game the character is always looking to the mousecursor with:
    image_angle = point_direction(x,y,mouse_x,mouse_y)
    Thats the reason why its stucking when its touching the walls when I am using the collision codes from this video
    is there any solution to this?

  • @KwakWack
    @KwakWack 6 ปีที่แล้ว

    Okay, he's adding up speed and position, is that supposed to make sense? I don't understand how this is even possible

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      I'd love to help, if you can be a little more specific on which part confused you exactly.

    • @KwakWack
      @KwakWack 6 ปีที่แล้ว

      I'm a total newbie so I don't understand how adding a collision speed will affect your final position in a right way

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว +1

      Ah. Well, I will say that this form of movement and collision checking isn't very good, so if you don't understand it, you needn't worry.
      What I was attempting to get at is this: when your player is moving, they're moving at x speed (whatever x is). We want to check and ensure they don't collide / get stuck, so we check their speed, + a collision speed, which would be a small amount of pixels ahead of whatever direction they're walking. By doing this, it would ensure the player never gets stuck in anything.
      However, it doesn't work great, and there are much better systems in place. Take a look at the perfect TDS movement system. I'll also be coming out with a better, updated movement system soon.

    • @KwakWack
      @KwakWack 6 ปีที่แล้ว

      Alright, thank you for this explanation. I've tried a similar method that really does not work with high speed collisions so that's why this whole collision speed is bothering me.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว +1

      Fair enough. The principal idea is that however fast you're moving, is how much ahead you need to check.

  • @realtroiiing
    @realtroiiing 5 ปีที่แล้ว

    This doesn't work at all,
    I have the character set to solid, and the wall set to solid, but my character moves right through it
    I tried making the movement using jump to point, and then I changed it to speed movement, but the character still moves through it.

    • @realtroiiing
      @realtroiiing 5 ปีที่แล้ว

      Saola Chan I figured it out. Have the controls be created in the create function rather than the actual keypress function

    • @realtroiiing
      @realtroiiing 5 ปีที่แล้ว

      @Saola Chan Put this code into the create event of your player object.
      image_speed = 0;
      walkSpeed = 1.5;
      collisionSpeed = walkSpeed + 2;
      Then, put this code into the step event of your object.
      if(keyboard_check(ord("D")) && place_free(x + collisionSpeed, y)) {
      x += walkSpeed;
      image_speed = walkSpeed / 4;
      sprite_index = Lucas_right;
      }
      if(keyboard_check(ord("A")) && place_free(x - collisionSpeed, y)) {
      x -= walkSpeed;
      image_speed = walkSpeed / 4;
      sprite_index = Lucas_left;
      }
      if(keyboard_check(ord("W")) && place_free(x, y - collisionSpeed)) {
      y -= walkSpeed;
      image_speed = walkSpeed / 4;
      sprite_index = Lucas_up;
      }
      if(keyboard_check(ord("S")) && place_free(x, y + collisionSpeed)) {
      y += walkSpeed;
      image_speed = walkSpeed / 4;
      sprite_index = Lucas_down;
      }
      if(keyboard_check(vk_shift)) {
      walkSpeed = 6;
      }
      if(keyboard_check(vk_nokey)) {
      image_speed = 0;
      image_index = 0;
      walkSpeed = 4;
      }
      Replace "Lucas_down" with the names of your sprites.
      For collision to work in this case, make the wall and your character solid, so when the character tries to move into the wall, it will be stopped.
      I hope this has helped you! let me know if it doesn't work though.

  • @gelatinbfdi2763
    @gelatinbfdi2763 ปีที่แล้ว

    beatbox

  • @ChuckySkullHead
    @ChuckySkullHead 6 ปีที่แล้ว +1

    It no do for me. It no work.
    EDIT: Also, my character walks ON the tree instead of behind it.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      Hmm. Download my project and compare it to yours, you may find the problem.

  • @armiefalconi5947
    @armiefalconi5947 6 ปีที่แล้ว

    this aint workin for me :( im making a mistake but what?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      Well, I've no idea either :) There are so many ways to make mistakes. If you're more specific, I might be able to assist .
      Are you getting an error? Is the game running?

  • @sonny12681
    @sonny12681 6 ปีที่แล้ว

    Why use code if you don't need to? Using code confuses me. I would rather use the drop menus.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 ปีที่แล้ว

      I get that. Drag and drop is much friendlier starting out. But it doesn't give near as much flexibility as code does.
      I've got a series that makes a game with drag and drop and then converts it to code, explaining each step along the way. I suggest you check that out when you're ready to move to code.
      The other big reason is that nearly every video and help article will be in GML not drag and drop, making it hard to find assistance.