GameMaker Studio 2: Action RPG Tutorial (Part 3: Tile Collision)

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.พ. 2025
  • ★ Source Code ▶ shaunjs.itch.i...
    ★ Support my work ▶ / shaunjs
    ★ Assets & Sprites ▶ shaunspalding.c...
    (NOTE: right click and hit "save as" if this link appears not to work, it's a Chrome issue)
    Learn to build a zelda like action RPG in GameMaker Studio 2, starting from nothing at all. This episode deals with colliding against a tilemap, a departure of sorts from the usual approach of colliding against object instances.
    These tutorials are supported almost wholly by wonderful people via Patreon, click the link above to get join them an access these episodes early, get instant access to source code for all videos and more.

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

  • @SaraSpalding
    @SaraSpalding  4 ปีที่แล้ว +85

    Scripts have changed! They now contain functions rather than being functions in their own right. When you create a script you will get a default function declaration. DO NOT DELETE THIS! Name it the same as your script and put your code *INSIDE* the function curly brackets.
    See this video for more information: th-cam.com/video/9nwlgfzyNzA/w-d-xo.html

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

      Yeah that tripped me up for a bit until I realized I was on a different version. Thanks for the great vids.

    • @P.WPlays
      @P.WPlays 4 ปีที่แล้ว

      Question: Do all of my sprites have to be the same size in order for this to work?

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

      @@P.WPlays no it doesnt but it might affect your autotiles in the future

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

      First I did it right without noticing it, because I'm used to use functions like that. Then I saw that you made different, and deleted the function, and everything stopped working. Got a hard brain glitch, and then I saw the update, lol.

    • @Mr.OhEmGee
      @Mr.OhEmGee 3 ปีที่แล้ว

      I would just like to say that you're now my favorite person simply for explaining this concept. I'm very brand new and was struggling like crazy with Cosmonaut's tutorials because they didn't explain this change and people in the forums and comments were either 1) just posting their code or 2) saying that it worked for them. THANKS!

  • @chris9085
    @chris9085 4 ปีที่แล้ว +171

    that "congratulations on making it to episode 3" at the beginning really made my day

    • @brycemallumakopp
      @brycemallumakopp 7 หลายเดือนก่อน +2

      it felt so personal. What a great way to start a tutorial/lesson.

  • @FelimSullivan
    @FelimSullivan 4 ปีที่แล้ว +143

    20:30 Everyone: don't do it
    Shaun editing: don't do it
    Shaun while recording: ..... so i made an oopsie

  • @wfkmm
    @wfkmm 3 ปีที่แล้ว +115

    Just a tip for everyone, DON'T PUT A SEMICOLON AT THE END OF THE MACRO LINE! It took me nearly 2 hours of troubleshooting and reading forums before I saw that tiny mistake, fixed it then SUDDENLY it's all hunky dorey.

    • @vaalalves
      @vaalalves 3 ปีที่แล้ว +10

      You mean like he explicitly told you not to do in the previous tutorial?
      Pay more attention lol.

    • @wfkmm
      @wfkmm 3 ปีที่แล้ว +40

      @@vaalalves it was a moment of not thinking lol, it happens to everyone

    • @pop-lw7cf
      @pop-lw7cf 3 ปีที่แล้ว +3

      thanks a lot man!

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

      Yeah it just happened to me despite the warnings. Thanks for the heads up I appreciate it

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

      Thanks bro

  • @MrYeune
    @MrYeune 5 ปีที่แล้ว +35

    I just wanted to say I appreciate that you recognize the drop-off. Please keep up the good work, even with the lessoned support after each.

  • @pumpthegamer
    @pumpthegamer 2 ปีที่แล้ว +8

    Hi Shaun! My son who's 8 yro and I love these tutorials. We're learning together how to make our first rpg game. Keep up with making these amazing material! 👏

  • @asianbronyman
    @asianbronyman 3 ปีที่แล้ว +65

    This is an old vid so IDK who'd see this but I got it to work. I did a few things tho. I found the issue was the game only thought that moving right/down set _collision to "true" and resetting speed to 0.
    1. Make sure there are no semicolons after each line in the MACROS file.
    2. The sPlayer and sPlayerRun sprites have identical sizes, origins, and collision meshes.
    3. Follow the instructions in Shaun's pinned comment on scripts.
    4. Change the brackets around a bit in playerCollision(). I used:
    "if(tilemap_get_at_pixel(...){ x -= mod TILE_SIZE; if(sign(hspeed == 1){ x += TILE_SIZE-1;} hspeed = 0; _collision = true;} x += hspeed
    The difference being the hspeed = 0 and collision = true line are put in a different area. Use the same approach for vertical/y position code.
    This took me like 2 hrs to figure out so if even 1 person saves time from this I'd be content.

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

      It's not in vein thanks

    • @missingeye2947
      @missingeye2947 3 ปีที่แล้ว +5

      life saver, thank you

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

      :( it doesn't work for me

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

      @@thelegendarymushroom80 what type of error message is it? It should say it somewhere.

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

      @@asianbronyman :( the game starts normal and I do not see anything in the output, but i'm not good at knowing what to look at in the output. But my player gets stuck very easily in the walls and if he walks up he stays stuck in the walls at the top, but he just glitches trough the walls at the right and can walk again after a few glitches.

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

    I love that you make these tutorials fun by actually having a sense of humor as opposed to some other youtubers. Thanks for another helpful vid, learning a lot.

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

    For everyone following along up to this point make sure to include that "return _collision;" statement within the brackets of the playerCollision script! I just wasted an hour troubleshooting to realize I left it out, and it broke my screenshake feature.
    As always, Thank you Shaun for all your hard work putting these up for us noobs :D

  • @psirenvct
    @psirenvct 4 ปีที่แล้ว +44

    For people having the glitch problem , be sur you have this: "if (sign(hSpeed) ==1)" and not this: if (sign(hSpeed ==1))
    and same for "vSpeed"
    at least it was the problem for me ;)

    • @zdzandro9804
      @zdzandro9804 4 ปีที่แล้ว +8

      @@xakees8541 i have that but i am still going though walls help

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

      only while moving left and up i am going though walls i have same but i isnt fixed help

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

      How the hell does one figure THAT out
      edit: I did that and the game now runs, but it crashes when I collide with the objects

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

      Lifesaver

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

      god sent!

  • @juanmarcelo589
    @juanmarcelo589 3 หลายเดือนก่อน

    Im following through your tutorials for some months now and i had the most accomplishment that i learned something when this code doesnt work in my version of gamemaker but i managed to fix it myself. Thanks for being such a professor o/

  • @MAYOFORCE
    @MAYOFORCE 2 หลายเดือนก่อน +3

    I was struggling with making the collision function work with the current version (0.3.98) and after some troubleshooting I figured out that gamemaker doesn't like operations applied to macros in functions. My solution was to add in a var at the top and make it copy the value of TILE_SIZE. Below is what I have for my version of the function, results are identical, very little is changed from the video:
    function PlayerCollision()
    {
    var _collision = false;
    //Macros can't have operations applied to them in this version
    var tilesize = TILE_SIZE;
    //Horizontal
    if (tilemap_get_at_pixel(collisionMap,x+hSpeed,y))
    {
    x -= x mod tilesize;
    if (sign(hSpeed) == 1) x += tilesize - 1;
    hSpeed = 0;
    _collision = true;
    }
    x += hSpeed;
    //Vertical
    if (tilemap_get_at_pixel(collisionMap,x,y+vSpeed))
    {
    y -= y mod tilesize;
    if (sign(vSpeed) == 1) y += tilesize - 1;
    vSpeed = 0;
    _collision = true;
    }
    y += vSpeed;
    //Return state of collision flag when done
    return _collision;
    }

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

    Attention: current version (v2023)!
    For the correct vertical collision, the origins of the sprites must be set to "Origin 8 x 23"!

  • @SquixHD
    @SquixHD 5 ปีที่แล้ว +21

    19:48 This is the exact reason why I decided to use the variable "ySpeed" instead of "vSpeed" cause I would make that mistake all the time

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

      Same here! especially when there is inbuilt vspeed and hspeed that you can also use by mistake for bad effect! :)

  • @jaydenmcfarlane27
    @jaydenmcfarlane27 5 ปีที่แล้ว +8

    I appreciate being thanked for making it this far lol.

  • @TheXedMeister
    @TheXedMeister ปีที่แล้ว +15

    This has been up for a long time - but if you are running into the teleporting glitch, I found it was because of shaun's usage of the if statement syntax confusing me.
    make sure it looks like this if you are used to using curly brackets with your if statements:
    if (sign(h_speed) == 1) {
    x += TILE_SIZE - 1;
    }
    h_speed = 0;
    _collision = true;
    NOT:
    if (sign(h_speed) == 1) {
    x += TILE_SIZE - 1;
    h_speed = 0;
    _collision = true;
    }

  • @toki4319
    @toki4319 3 ปีที่แล้ว +9

    All of your tutorials are great. Thank you for everything
    The following are requests
    (1) Tile collision for slope tiles
    (Pixel perfect collision would be ideal, but slope tiles can be limited to 45 degrees)
    (2) Wall sliding when colliding with tiles

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

      Agreed. I would love to see an updated tutorial on slope tile collision using 45-degree tiles. Using this system with diagonal wall sprites doesn't look/feel right for obvious reasons.

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

    Can't wait for the next video, its the first series I watch from you where I have to wait ):

  • @universalgamer9615
    @universalgamer9615 5 ปีที่แล้ว +20

    Ok first: hi
    Second: I just came to this channel on pure whim
    Third: I plan on getting the program to help myself out with making games since it’s on sale

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

    Doing this series now in 2021, great work! Really enjoy your stuff!

  • @jacobroys4327
    @jacobroys4327 5 หลายเดือนก่อน

    Here in 2024 I made it to episode 3 with my own assets, thanks for the lessons so far man!

  • @makell6597
    @makell6597 4 หลายเดือนก่อน

    so far so good i manage to keep it up and no mistakes and seams to work on current version. im working on my own assets, but i want to keep going on what here.

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

    Though I know this tutorial was made a while ago, for those if you having.. teleportation problems, Gamemaker has a built in property - hspeed. If you were autocompleting your own variable hSpeed, it may have autocompleted the lowercase built in hspeed instead. Double check your code to make sure you have hSpeed and not... hspeed.

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

      THAT WAS IT! Thank you!!

    • @artovum
      @artovum 4 หลายเดือนก่อน

      Hey thanks :) This is the problem I was having!

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

    my player is off with the collisions. the collisions stop me but way to early. im like 2 tiles before the collision and im blocked.

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

    Loving the series! Thanks so much for your work and great tutorials Shaun!

  • @Robzvideogamez
    @Robzvideogamez 4 ปีที่แล้ว +3

    About the empty tile on the top left, it is because that is the eraser tile by default. This way you con use that spot as the eraser when painting on tiles.

  • @npola3713
    @npola3713 11 หลายเดือนก่อน +2

    For anyone that's having issues with their sprite moving diagonally or teleporting through hitboxes. It'll be fixed if you check that all your "hSpeed" and "vSpeed" variables are written the same way. If that doesn't work try replacing "hSpeed" with "xSpeed" and "vSpeed" with "ySpeed".

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

      That worked! Thank you so much!

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

      @@aprilautumn5444 How did you make it work mine still glitching
      if (tilemap_get_at_pixel(collisionmap, x + xspd, y ))
      {
      x -= x mod TILE_SIZE;
      if (sign(xspd) == 1) x += TILE_SIZE -1;
      xspd = 0;
      _collision = true;



      }

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

      @@renzypers so it fixed the glitching through, but mine is now bouncing back only when I walk to the right against a wall. I went through the code again but I'm not sure what's making that happen. Are you having that same problem?

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

      @@aprilautumn5444 yes and i change the #macro tile_size to make the bouncing small. I cant make it like in the vid where its like smooth but its fine for me

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

      @@aprilautumn5444 i fix it now its not bouncing anymore just chane your playermovement script to this function playermovement() {
      // Diagonal fix
      var horizontal_input = keyright - keyleft;
      var vertical_input = keydown - keyup;
      if (horizontal_input != 0 && vertical_input != 0) {
      // Prioritize horizontal movement
      if (abs(horizontal_input) > abs(vertical_input)) {
      inputdirection = point_direction(0, 0, horizontal_input, 0);
      inputmagnitude = abs(horizontal_input);
      }
      // Prioritize vertical movement
      else {
      inputdirection = point_direction(0, 0, 0, vertical_input);
      inputmagnitude = abs(vertical_input);
      }
      } else {
      inputdirection = point_direction(0, 0, horizontal_input, vertical_input);
      inputmagnitude = (horizontal_input != 0) or (vertical_input != 0);
      }
      }
      and in your obj_player or oplayer whatever you name your character just go to step event and change the spdrun or speedwalk value and thats it

  • @srspanksalot4501
    @srspanksalot4501 3 ปีที่แล้ว +23

    if you're having a problem where when moving right your character teleports over and over. add an if statement for the first line
    if(sign(hSpeed == -1)){x -= x mod TILE_SIZE}

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

      what about down

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

      I had this problem and figured out that it was caused by not changing some of the "x"s to "y"s when copying the collision code

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

      for me when i replace my code with it it made the problem so i keep my code and not thing happens

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

    I'm having an issue where the collision only works if I'm moving up and/or right. If I'm moving down and/or left, my character glitches out and passes through the wall.
    IDE Version: 2.2.5.481 Steam
    Please help.

    • @alexanderm.clinthorne4368
      @alexanderm.clinthorne4368 4 ปีที่แล้ว +1

      this is exactly my issue. let me know if you figure it out!

    • @alexanderm.clinthorne4368
      @alexanderm.clinthorne4368 4 ปีที่แล้ว +3

      figured it out! I had vspeed, instead of vSpeed in the oPlayer events

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

      @@alexanderm.clinthorne4368 8 months later and you saved my butt!
      I knew when I made the variable I was going to get tripped up on it somewhere.

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

      I have the same problem, but my vSpeed its ok, and it keeps happening

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

    I spent my time trying to wrap my head around modulo. I have a decent background in computer science, but my head always explodes with modulo, especially when it modifies a value. For those struggling with it it found another way to implement tile collision without having to think too hard on the math behind it.
    if(tilemap_get_at_pixel(collisionMap,x+hSpeed,y))//Is there a col tile at upcoming location?
    {
    while(tilemap_get_at_pixel(collisionMap, x+hSpeed,y) == 0){//While the player has not collided with col
    x += hSpeed;//Increase x
    }
    hSpeed = 0;
    }
    I hope this makes a bit more sense. Basically it detects for the collision just as Shaun has suggested, then inside that statement it determines if the player has actually collided based on it. If they haven't it just keeps x incrementing as normal. but as soon as it hits it breaks out of the while loop and sets our horizontal speed to 0.

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

    Hey I don't know if u are going to see this but I have an issue, when I try launching the game it tells me that there is a problem at line 4 : if (tilemap_get_at_pixel(collisionMap, x + hSpeed, y))

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

      i have the same issue ^
      i figured it out ,, you're gonna wanna make a new line on top and type: function PlayerCollision()
      on line 2 you wanna bracket and close bracket the rest of the lines. ur code should look like this
      function PlayerCollision()
      {
      var _collision = false;
      //Horizontal tiles
      if (tilemap_get_at_pixel(collisionMap, x + hSpeed, y))
      {
      x -= x mod TILE_SIZE;
      if (sign(hSpeed) == 1) x += TILE_SIZE - 1;
      hSpeed = 0;
      _collision = true;
      }
      //Horizontal Move Commit
      x += hSpeed;
      //Vertical tiles
      if (tilemap_get_at_pixel(collisionMap, x, y+ vSpeed))
      {
      y -= y mod TILE_SIZE;
      if (sign(vSpeed) == 1) y += TILE_SIZE - 1;
      vSpeed = 0;
      _collision = true;
      }
      //Vertical Move Commit
      y += vSpeed;
      return _collision;
      }
      this worked for me ^^ hope it does for you too

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

      @@GeorgeSasaki You saved me a lot of trouble, friend. Thanks a bunch.

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

    A fix for teleportation I did was instead of "+=" I accidentally used "=+" so if you have a similar problem check that.

  • @jaysanders1670
    @jaysanders1670 5 หลายเดือนก่อน +2

    Hey, I've encountered the weird teleporting glitch like many others using newer versions of GM, but I have also had no luck with anyone's solutions posted here in the comments. Every single one does not collide at all with anything. I make sure to change any global variables if necessary and also try changing them in the new code itself. Is there something I need to be changing in Step or Create? Is it something with the player?

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

    please keep this series up its helping a lot XD

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

    So im having an issue where the collision works for right and down movement. I've deduced that since those are positive value movements that it isn't working for only negative values. (it just jumps through the wall for negative movement). Any tips? Im not using the same sprites but I don't think that's the cause.

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

      check your code for typos, i recreated this by having x += hSpeed; where i should have y += vSpeed;

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

      the same for me, but instead of right and down its left and up the ones that work for me

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

      Yes i have the same issue

  • @bugsydev
    @bugsydev 4 ปีที่แล้ว +9

    Hey Shawn!,
    I tried using this in my game and I've run into a problem.. on certain collision tiles the player glitches back and forth, or no collision happens at all

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

      yeah i've had that problem too:(

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

      same

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

      Check to see if the macro TILE_SIZE is 16. I thought I heard him say 60 so I was glitching through walls and whatnot.

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

      @@JosephBoooy Thank you for this. I was trying to figure out why my character kept glitching back from the tile and would get stuck when moving down against a tile while also moving left or right. Turns out my TILE_SIZE was 6 instead of 16. Guess I didn't hit the 1 key hard enough lol.

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

      @@UltraClue You're Welcome! I forgot I made this comment since it was a year ago, lol!

  • @justhere2153
    @justhere2153 4 ปีที่แล้ว +12

    If I wanted to use my collision mask for the player to collide into tiles, how would I go about doing this?

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

      if place_meeting(x,y,oPlayer) //write this into the step event of the obj ,which collision you want to use
      {
      }

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

      @@thelegendarymushroom80 it’s been a while but thanks

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

      @@justhere2153 hey I'm still a little confused on how to use the collision mask of the player rather than the sprite origin. do you mind sharing how you were able to achieve this? 😀

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

    to anyone trying to figure out why there collision works only sometimes:
    1) check the code matches the one in the video.
    2) IF YOU USE A DIFFRENT TILESET SIZE MAKE SURE TO WRITE THE CORRECT ONE IN THE MACROS!!!!! i spent an hour trying to figure out why it didnt work and then i realised that i wrote 16 as the TILE_SIZE instead of my actual tile size which was 8

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

    I'm having a problem with speeds and collision, ok so after some testing, I have 2 speeds which my player can go, one is below 1 and one is over 1, when I go slow, collision for moving right and down is a bit glitch and moves me the other direction when i go fast, everything is just fine, I don't know what numbers to change in my code? do I need to have a fast speed, or can I change something in the collision code?

  • @Thrallking
    @Thrallking 2 ปีที่แล้ว +5

    I'm having an issue where x collision functions great but my character just teleports slightly to the left and moves through the collision tiles when moving up or down, all of my variables are reversed as they should be.

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

      check to make sure you changed all of the hSpeed to vSpeed in the vertical part of the PlayerCollision

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

    I spent an hour trying to figure this out so someone probably needs it. Right click can delete tiles, if that doesn't work then select a new tile from your tile set (it doesn't have to be one you actually have) and a new bar will appear at the top of the screen that has an erase icon in it, if you click that it will put you specifically into erase mode.

    • @_shinyrinn
      @_shinyrinn 5 หลายเดือนก่อน

      i'm very late replying to your comment, but if anyone passes by and still reads this:
      typing on your keyboard (in room editor while having a tileset selected, and the MSpaint feature/thing):
      D is pencil
      E is eraser
      F is bucket fill
      L is line tool
      R is rectangle tool
      C is circle tool
      S is select/crop tool

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

    Very informative and interesting. thanks

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

    Help, my player sprite "bounces" off of a collision tile when I run into it from the left and top. I have no idea what causes the sprite to be pushed back by a full tile.

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

      same problem

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

      Make sure your "sign(vSpeed)" check does "x += TILE_SIZE - 1;" and NOT "x += x mod TILE_SIZE - 1;"

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

      same problem, did you resolve it?

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

      i just replaced every "TILE_SIZE" by 16 and it worked for me

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

      @@prunow21 I had also done this, but the real problem was in the order of the images in the sprite and the collision mask, after I fixed it, it worked perfectly, including with TILE_SIZE

  • @ruudwestendorp3761
    @ruudwestendorp3761 2 ปีที่แล้ว +9

    Okay maybe I am missing something. But the code seems to work fine without:
    ""x -= x mod TILE_SIZE;
    ...
    x += TILE_SIZE - 1; }"
    Just the "hSpeed = 0;" and _collision = true" in the if statement.
    If I do it like that what do I miss?
    // Edit:
    Okay so I found out that this would break the collision while rolling. What I want to do is position my character a bit further from the walls to make it look somewhat nicer.
    if (tilemap_get_at_pixel(collisionMap, x + hSpeed -3, y) && keyLeft == 1)
    { hSpeed = 0;
    _collision = true;
    }
    else if (tilemap_get_at_pixel(collisionMap, x + hSpeed + 3, y) && keyRight == 1)
    { hSpeed = 0;
    _collision = true;
    }
    This worked (and same for up and down vertical movement, but sa said, that breaks my rolling collision. Im gonna keep at it. If I find out how i'll update here, or if anyone has pointers, would be nice. :)
    // Edit2:
    So the && statement made collision false when I did not push the arrow key, now it works and I dont clip into walls as much :) Below now works. Sharing is caring.
    // Horizontal Tiles
    if (tilemap_get_at_pixel(collisionMap, x + hSpeed -3, y))
    { hSpeed = 0;
    _collision = true; }
    if (tilemap_get_at_pixel(collisionMap, x + hSpeed + 3, y))
    { hSpeed = 0;
    _collision = true; }
    // Horizontal Move Commit
    x += hSpeed;
    //Vertical Tiles
    if (tilemap_get_at_pixel(collisionMap, x, y + vSpeed - 8))
    { vSpeed = 0;
    _collision = true; }
    if (tilemap_get_at_pixel(collisionMap, x, y + vSpeed))
    { vSpeed = 0;
    _collision = true; }
    // Horizontal Move Commit
    y += vSpeed;

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

    How odd, can not get this to work in GM 2.3. Check my code many times it's exact and the script (function) is in the function area as script video shows. Any tips why collision is not working?

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

    Hey shaun! I already have a problem for some reason and was hoping you can help me! When I get to the end ish of the video, and try to play it, I get an 2 errors that seem to correspond with the “layer_tilemap_get_id” and “sprite_get_number” lines. Do those not work now that it has updated? Pls help! 😅

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

    I'm having an issue where the script PlayerCollision has forced the player object outside the window- if I push 'down' I can just about see its feet at the top of the screen but then it disappears. It's like the entire Tile Layer is forcing the player out (it's definitely something to do with the tile layer, if I take that out the player object is back on screen).
    I've gone through and I'm pretty sure I've copied the code line for line- at this stage the only difference between Shaun's project and mine is that I have a different sprite that I drew myself. Is there anything obvious that I've done wrong?

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

      still need help? i found out how to fix it

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

      how@@TheFoggyYT

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

    I had an issue with my player character shaking back and forth when colliding diagonally with a wall. I was able to fix this by changing line 4 of the PlayerColission script
    From:
    if (tilemap_get_at_pixel(collision_map, x + horizontal_speed, y))
    To:
    if (tilemap_get_at_pixel(collision_map, x + horizontal_speed + sign(horizontal_speed), y))
    That way, it checks 1 pixel ahead of where the player is about to move.

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

      does it work for Vertical coliding to because i get teleportet back when i colide vertical

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

      excuse me but what should i do? because with most tiles i just walk right past them? like i glitch to the other side while sometimes some parts of the wall are perfectly fine

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

      Was this for a previous version of Game Maker because I don't have those problems at all.

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

      I have this as well except it is for when i collide with a wall when moving downwards.

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

      @@simonv281 Ah i found the error.
      For me, on LINE 19 of PlayerCollision script. It is in the vertical tiles section.
      //Vertical Tiles
      if(tilemap_get_at_pixel(collisionMap, x, y + vSpeed))
      {
      y -= y mod TILE_SIZE;
      if(sign(vSpeed) == 1) y += TILE_SIZE - 1;
      vSpeed = 0;
      _collision = true;
      }
      just make sure that every x is changed to a y.

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

    Not only are tile collisions faster to begin with, but now we don't need to create a for loop and check every pixel of hSpeed and vSpeed for a collision. Although that can be prevented by checking the bounding box of the collision object. I haven't tested it out yet, but I guess you could just set your position by checking either the top, right, bottom or left side of a bounding box and either adding or subtracting half the sprite width or height of the player to it's x or y to set it to the correct position.

  • @casmd2131
    @casmd2131 3 ปีที่แล้ว +4

    If your having problems with your player going inside tiles, the end of the video says to put the collision layer underneath the player layer.

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

      this saved me 10 years thx

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

      @@fierzy_new I’m happy this helped.

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

    ok, so i'm having an issue were the collision is offset from the sprite one tile to the left and one tile down. any way to fix this?

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

      check your sprites origin is set to middle bottom and not away off from the sprite.

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

      @@scotsparaman Thanks Michael, that was exactly my problem. Kudos

  • @deansoups
    @deansoups 4 หลายเดือนก่อน

    !! Really simple solve for teleporting glitch that I had !! All I did was change the origin point of sPlayer_run to be the same as sPlayer. Both should be bottom center. Hope that helps!!

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

    iv been following the tutorial and i got stuck in here, i have a player that walk and changes sprites from the same sprite for the diferent directions, but i dont know what i did wrong (i follow this tutorial step by step, and add the function "name" (){ at the start and } at the end) the game lunches normaly but the screen is all black, there's nothing. Help pls

  • @adrianiskra3521
    @adrianiskra3521 4 ปีที่แล้ว +3

    When I write x += TILE_SIZE - 1; theres an error: Assignment operator expected and next one error: malformed assignments statement, what is wrong? HELP PLEASEEEEEEEEEE

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

      I think you might have used a ';' after TILE_SIZE in the macro

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

      @@msPacmanization thanks

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

    I have a question, my character is a bit bigger than yours and is a bit annoying that only 1 pixel collides. How can I make the collision area bigger?

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

      This is really late response, but you can create a separate object that is a 16 by 16 sprite that has all the movement code in it, and then have another object follow the x and y of that object. For example you could create a playerHitbox and player object, the playerHitbox having all the movement code and the player having all the animation code. Then you can have it so in the player code end step event you can run:
      x = playerHitbox.x; y = playerHitbox.y - (Enter how much taller than 16 your character is here);
      This should work!

  • @PocketDeerBoy
    @PocketDeerBoy 8 หลายเดือนก่อน +1

    I'm making it to episode 3 for the second time because i got distracted with trying stuff in a bunch of different game engines, your tutorial series are still some of the most useful tutorials i've had the pleasure of following :D

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

    FOR PEOPLE WALKING THROUGH WALLS:
    I had this problem where my character would go through walls if the movement was LEFT or TOP ( -1, 0 ) or ( 0, -1 ), and that was because I was following what Shaun was saying but differing with the IFs statements (for both, X and Y). He is using ONE-LINE IF, which makes the content after the first line go OUTSIDE the if statement, but I was placing in both ifs, the content INSIDE the if statements. And that's probably what you might be doing. Here I leave the snippet so you can copy and paste it.
    function PlayerCollision(){
    var _collision = false;

    if ( tilemap_get_at_pixel( collisionMap, x + hSpeed, y ) ) {
    x -= x mod TILE_SIZE;
    if ( sign( hSpeed ) == 1 ) {
    x += TILE_SIZE - 1;
    }
    hSpeed = 0; // THIS PIECE OF CODE WAS INSIDE THE ABOVE IF. IT SHOULD BE OUTSIDE.
    _collision = true; // THIS PIECE OF CODE WAS INSIDE THE ABOVE IF. IT SHOULD BE OUTSIDE.
    }

    x += hSpeed;

    if ( tilemap_get_at_pixel( collisionMap, x, y + vSpeed ) ) {
    y -= y mod TILE_SIZE;
    if ( sign( vSpeed ) == 1 ) {
    y += TILE_SIZE - 1;
    }
    vSpeed = 0; // THIS PIECE OF CODE WAS INSIDE THE ABOVE IF. IT SHOULD BE OUTSIDE.
    _collision = true; // THIS PIECE OF CODE WAS INSIDE THE ABOVE IF. IT SHOULD BE OUTSIDE.
    }

    y += vSpeed;
    return _collision;
    }

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

      Thank you, that was exactly the problem I was having and your code fixed it, I don't quite understand what I had that was wrong but on episode 3 I am content with it just working as intended.

    • @Enlapse.
      @Enlapse. 3 ปีที่แล้ว

      @@WolchBot Probably you didnt use a one line if as shaun is doing, but still copying his code. I explained why this happens on my first comment, so if that what happened me was the same that happened to you, the answer is still there. If you have any more troubles about this issue and have a copy of your old code, tell me and I will try to explain you. :) Have a nice day!

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

      Perfect! that was the answer!

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

      amazing!!

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

      nevermind me. I'm an idiot. I had "hspeed" in as one variable instead of "hSpeed" (cap S).

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

    Is this tile-based approach suitable for use with the inbuilt pathfinding modules? The super sweet mp_add_instances function seems to only take objects as arguments, is there any way to address this without the need to manually create corresponding objects for each impassable tile?

    • @SaraSpalding
      @SaraSpalding  5 ปีที่แล้ว +2

      there are mp_grid functions that create and use a grid that you can use the contents of the tilemap to populate.

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

    Still annoying how the character flickers 1 pixel when moving diagonal from tutorial part 1

  • @vaughanschmidt2130
    @vaughanschmidt2130 5 ปีที่แล้ว +3

    Quick question! Since this system presently only works based on the origin of the sprite, will it eventually be changed to use the player's collision box? And if so, how much longer will that be, and is it a simple process?

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

      The collision mask is for other objects; the origin is used (in this case) for the tilemaps.

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

      @@christianzhouzheng Basiccaly, the collison mask is the hitbox.

  • @Rangal25
    @Rangal25 4 ปีที่แล้ว +8

    I am having a problem where the player slightly clips into the geometry. The collision itself is fine, its just that the player sprite goes into the geometry a bit

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

      sounds like you need to widen your collision mask

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

      i know this comment is two years old, but the problem is that shaun is using a tile collision system, meaning that the collisions take your player's origin point into consideration, instead of the collision mask, sadly, im not sure of a way to make it so it using the collision mask instead

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

      @@oniontherock7204 Yesss, I've been trying to tweak it for so long, because I don't really like the clipping.

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

    I’m having a problem where when I start the game it says variable undefined in the
    If (tilemap_get_at_pixel(collisionMap, x + hSpeed,y))
    Section help would be greatly appreciated

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

      Make sure you have the collision script inside of a function and double check that the spelling of collisionMap matches what you have in the object create. That one got me good

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

      I had the same problem; I fixed it by surrounding the code with “function PlayerCollision()”, and some curly brackets ofc

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

      I surrounded my code with that as well, I'm super new to this still, but I still get the same error as before and I'm not entirely sure why.
      PlayerCollision Script:
      function PlayerCollision()
      {
      var _collision = false;
      //Horizontal tiles
      if (tilemap_get_at_pixel(collisionMap, x + hSpeed, y))
      {
      x -= x mod TILE_SIZE;
      if (sign(hSpeed) == 1) x += TILE_SIZE - 1;
      hSpeed = 0;
      _collision = true;
      }
      //Horizontal Move Commit
      x += hSpeed;
      //Vertical tiles
      if (tilemap_get_at_pixel(collisionMap, x, y + vSpeed))
      {
      y -= y mod TILE_SIZE;
      if (sign(vSpeed) == 1) y += TILE_SIZE - 1;
      vSpeed = 0;
      _collision = true;
      }
      //Vertical Move Commit
      y += vSpeed;
      return _collision;
      }
      create event (at the very top)
      function PlayerCollision(){
      collisionMap = layer_tilemap_get_id(layer_get_id("col"));
      }
      // my tileset layer is "col" no caps.
      i keep seeing this issue with this particular line a lot and i'm not entirely sure why nothing has helped me. :/

    • @GarryStinger
      @GarryStinger 8 หลายเดือนก่อน

      @@rianano3936YOU ARE A LIFESAVER THANK YOU 🎉

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

    I believe the blank tile in tilesets is the "Air" tile in the actual Tile array. This happened for me when each tile was represented as an unsigned integer and I just assigned 0 to not draw anything

  • @michaelcapone175
    @michaelcapone175 2 ปีที่แล้ว +10

    Script for GMS 2.3 without typos. If you're still using GMS 2.2 get rid of "function PlayerCollision() {" and its ending "}"
    function PlayerCollision() {
    var _collision = false;
    // Horizontal Tiles
    if (tilemap_get_at_pixel(collisionMap, x + hSpeed, y))
    {
    x -= x mod TILE_SIZE;
    if (sign(hSpeed) == 1) x += TILE_SIZE - 1;
    hSpeed = 0;
    _collision = true;
    }
    // Horizontal Move Commit
    x += hSpeed;
    // Vertical Tiles
    if (tilemap_get_at_pixel(collisionMap, x, y + vSpeed))
    {
    y -= y mod TILE_SIZE;
    if (sign(vSpeed) == 1) y += TILE_SIZE - 1;
    vSpeed = 0;
    _collision = true;
    }
    // Vertical Move Commit
    y += vSpeed;
    return _collision
    }

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

      Literally a life saver, thank you.

    • @Leona-o_o
      @Leona-o_o ปีที่แล้ว +2

      did not work

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

      based.

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

      Literally already all of this (except my variables are horizontalSpeed and verticalSpeed), but the code doesn't work. At least, not with the latest GM version; I keep teleporting through the collision walls.

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

    I'm having trouble coding the vertical player collision, i've set up the Horizontal, but whenever, i attempt to vertically run my player in game i teleport through the walls ive set, im not sure what im doing wrong, do you of of any solutions? Thanks.

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

      check if you've used vspeed instead of vSpeed

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

    Is there an easy way to modify this collision script to handle triangle colliders, and not just square colliders? If not, I think it would make an awesome bonus video.

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

    i can move up or down. when i press up i go left and same for down i go left. kinda confused idk how to fix it

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

    Hey anyone know how I can stop my Player visually vibrating when it collides with a wall? It seems to only happen when I'm moving in two directions at once (I.e. Up and left at the same time)

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

    I’m using the newest version of game maker, and the -1 at the end of if (sign(hSpeed) ==1) x+= TILE_SIZE -1 is causing all sorts of errors in my code, like proceeding variables no longer being read correctly, and the -1 being read as a statement instead of as part of the equation. Can anyone help me on this? Same thing is happening with the vertical line too.

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

      Haven't used 2.3 yet, but here are two things to try:
      1 - Try wrapping brackets around it: if (sign(hSpeed) ==1) {x+= TILE_SIZE -1;}
      2 - Check your macros in the MACROS script and make sure that you are not ending them with semi-colons.

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

      @@michaelcapone175 This worked for me, except i used: x+= (TILE_SIZE-1)
      ;
      as opposed to {x+= TILE_SIZE -1;}

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

    HELP!
    "x += TILE_SIZE - 1" at 7 line isn't working somehow, it marked as a sintax error
    same part with just "x += TILE_SIZE" (without "-1") works without errors, but that doesn't make any sense...

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

      Everything else is working, if I put 15 instead of TILE_SIZE - 1 it runs smooth. Mysterious stuff.

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

      @@petrfrolov1591 Check to make sure your TILE_SIZE macro doesn't have a semicolon at the end of the line.

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

    I have a problem that has to do with your platformer series:
    when i create the collision calculation thingy it works perfectly fine... but if i then change the "oWall" to Wall with:
    Wall = oWall || oBreakable;
    it only works for the oWall object.... and if i then change the order of the objects in the objects tab which is: "oWall --> oBreakable" to "oBreakable --> oWall" it only works for the oBreakable... which i could atleast understand abit... but then if i change the first one to another object instead....... it collides with that object... so if i do "oInstaDeath --> oWall" even tho there isnt oInstaDeath in the ENTIRE code it collides with the oInstaDeath... it always collides with the 2nd object in the objects tab and idk why.... maybe its a bug but its really peculiar...

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

      if you want to see the code here it is:
      //Calculate Gravity
      vsp = vsp + grv;
      if (place_meeting(x,y+1,Wall))
      {
      jumps = jumpsmax;
      }
      else
      {
      if (jumps == jumpsmax) jumps -= 1;
      }
      if (key_jump) && (jumps > 0)
      {
      jumps -= 1;
      vsp = -9;
      }
      if (vsp < 0) && (!key_jump_held)
      {
      vsp = max(vsp,0);
      }
      //Horizontal Colision
      if (place_meeting(x+hsp,y,Wall))
      {
      while (!place_meeting(x+sign(hsp),y,Wall))
      {
      x = x + sign(hsp);
      }
      hsp = 0;
      }
      x = x + hsp;
      //Vertical Colision
      if (place_meeting(x,y+vsp,Wall))
      {
      while (!place_meeting(x,y+sign(vsp),Wall))
      {
      y = y + sign(vsp);
      }
      vsp = 0;
      }
      //Walljump
      if (onwall != 0) && (!place_meeting(x,y+1,Wall)) && (onground == 0)
      {
      if (place_meeting(x-1,y,Wall)) sprite_index = sWallJumpL;
      else
      {
      if (place_meeting(x+1,y,Wall)) sprite_index = sWallJumpR
      }
      jumps = 0;

      if (!key_climb) && (!key_jump_held)
      {
      vsp -= vsp_wall_friction;
      }
      else
      {
      if (key_climb) && (!key_jump) && (did_wall_jump == 0)
      {
      vsp = (key_down - key_up) * wallvsp;
      }
      }

      if (key_jump) && (jumps == 0)
      {
      walljumpdelay = walljumpdelay_max;

      if (key_climb) && (!key_down) && (!key_up)
      {
      if (key_right) || (key_left)
      {
      hsp = -onwall * hsp_wjump;
      }
      else
      {
      hsp = 0;
      }
      }
      else
      {
      if (!key_climb)
      {
      hsp = -onwall * hsp_wjump;
      }
      }
      vsp = vsp_wjump;

      hsp_frac = 0;
      vsp_frac = 0;
      jumps = jumpsmax - 1;
      did_wall_jump = 1;
      alarm[1] = 20;
      }

      }
      else
      {
      if (onground == 0)
      {
      sprite_index = sPlayer
      }
      }
      y = y + vsp;
      var grv_final = grv;
      var vsp_max_final = vsp_max;
      if (onwall != 0) && (vsp > 0)
      {
      grv_final = grv_wall;
      vsp_max_final = vsp_max_wall;
      }
      vsp += grv_final;
      vsp = clamp(vsp,-vsp_max_final,vsp_max_final);

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

    I'm having an issue where my player movement is messed up, he does not move forward and back or left to right really, only diagonally. I'm unsure where I messed up, can anyone help me out please?

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

      exact thing happened with me, im working on a fix now :/

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

      @@dopamine7344 I redid the part where he put the movement script back in, fixed it, check it more carefully than I did, lol

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

      @@Seekerofpizza Hi man, can you please please tell me which minute of the video you are referring to? I have the exact same problem

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

      @@Nemesi13 i am having the same problem can you guys help please
      EDIT: my mistake i had v += hSpeed instead of v += vSpeed

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

      I had the same problem but managed to fix it by removing the movement bit from the script and putting it back into the step event. You do have to make sure it’s underneath the script in the step event though. And I’m having problems with the player walking through walls too, but I’ll let you know if I figure out a way to fix that too.

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

    Tile 0 is likely a null tile or no (empty) tile. It would be the default the tilemap initializes to, and when selected, would set the tiles back to empty.

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

    great easy tutorial to follow. I'm coming from Construct 3 and Unreal. Anyways I'm having an issue with passing through my collision. Are there settings I should use specific to tilesets?

  • @MrLuigi-pe8tn
    @MrLuigi-pe8tn 4 ปีที่แล้ว

    I need help on the collision...
    So, I have multiple different tiles that I want to check which one the player is on (Different walls and ground types). Is there a way to make the game check which tile you're on so I can do different things for different tiles?

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

    why is it teleporting when going up and left? is there anything wrong??? The new version takes this code differently?
    function PlayerCollision()
    {
    var _collision = false;
    //Horizontal tiles
    if (tilemap_get_at_pixel(collisionMap, x + hSpeed, y))
    { x -= x mod TILE_SIZE;
    if(sign(hSpeed == 1)) x += TILE_SIZE - 1;
    hSpeed = 0;
    _collision = true; }
    // hor move commit
    x += hSpeed;

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

    So i've completed everything but when i play my game the Sprite is in the top left corner and is "stuck" in place he does all of the movements but can't get out of the wall? **Fixed it. i had made the x *=+* hSpeed when its supposed to be x *+=* hSpeed

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

      This fixed my problem, thank you!

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

    please help me. ( i know this has to do with nothing, but please help me anyways i really need help, someone ) when i walk into a wall, i can only move up and down, but that's now even all, i can only move up and down if i face to the right and not the left. if i face to the left i cant move. if i face to the right i can only move up and down. please help me someone i beg you

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

    For some reason regardless of whether my grid is on or off in the room view, or I change the colour... I cannot see the grid, ever!

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

      Maybe it's because you have the layer of the tiles under that of the room. Go here: 21:23

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

    having issues with collision working properly sometimes it just fails and cant walk left if im colliding up or down

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

    Do you have to make all tilesets 32x32 or can you use any size but multiplied by 2? say i have tiles that are 22x22 would i need to make a tileset that is 44x44?

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

    "Statistically if you've made it this far you're doing very well"
    Joke's on you I couldn't get the previous episode working so my character wouldn't play animations going up or left so I had to do it a different way, but I'm here because I believe I can glean something anyway despite my utter lack of ability

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

    Hello,
    I become a Error in this Line:
    if (sign (hSpeed) == 1) x += TILE_SIZE - 1;
    ErrorMessage: unnecessary expression (-1) used as a statement.
    Whats wrong oO

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

      same, did you resolve it?

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

      @@mthslm yes I look later ok

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

      @@devchirurgie4757 ok, thanks

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

    I'm having a bit of trouble where my player will do this thing where if you run into a wall going down or right it will teleport me back a few pixels and will do that every time, IDK how to fix it :(
    Edit: I fixed it but I had to set the TILE_SIZE to 1, I don't know if this will cause any problems

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

      Idk lol but thank you because that fixed mine too

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

      Do you know if changing the TILE_SIZE caused any problems?
      Edit: Actually never mind, I'm just dumb. I had the TILE_SIZE at 60 instead of 16.

    • @Maumauemmo
      @Maumauemmo 8 หลายเดือนก่อน

      It’s been a few years, but I still wanted to thank you! This fixed it for me!!!

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

    shaun please reply on this message, it does work for me but i end up glitching through some of the walls any help please?

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

    Does anyone know if there's a way to keep the player from clipping halfway into the walls when moving horizontally? I know that's the way it's supposed to be, but I don't like the way it looks.

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

      I really want to know how to do this too. You can use an object based collision, but i really like how easy it is to draw tiles as opposed to drawing objects. Did you ever figure out anything?

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

      @@jamesharrickey3580 No, I haven't.

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

    i dont understand teh mod part. If my current x value is 200, and we are in range of the collision map, 200 mod 16 would be 8, and I move 8 units to the left? @ShuanSpalding i dont understand

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

    Im having problems clipping and teleporting through the collision object, ive tried fixing it by listening to comments but nothing seems to work?

  • @Ne-tp8bk
    @Ne-tp8bk 2 ปีที่แล้ว

    quick question:
    is there a way for the player to collide with the collision mask instead?
    because when colliding with the tiles on the map, I notice that the player is using the origin of the sprite as a collision mask and not the collision mask itself
    Is there any way to make it collide with the Collision mask instead of the sprite origin?

    • @Ne-tp8bk
      @Ne-tp8bk 2 ปีที่แล้ว

      Nvm I found a way around it

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

      @@Ne-tp8bk what was the way?

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

      @@Ne-tp8bk how did you do it

  • @jason256-8
    @jason256-8 2 ปีที่แล้ว

    Second problem here. Again, I cannot put codes in separate scripts because my MacBook cannot recognize variables in them even though the variables in the code are being used by the objects using the scripts. Secondly, after I applied both scripts into my project, my player managed to get blocked by the s_Col tiles but somehow, the animation was lost.

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

    I have this issue where at the end of the player collision script i put }, right? but its still giving me an error saying "Got '}' (eof) expected '}' or "end"

  • @LilyForster-w6b
    @LilyForster-w6b 2 หลายเดือนก่อน

    Not sure if anyone will see this, but does anyone have any tips on making it hitbox-to-tilemap based collision instead of using the origin? I've tried out some things, using the bbox values and adding bits on, but nothing seems to work properly. Any help would be much appreciated!

  • @stinker-frog
    @stinker-frog 4 ปีที่แล้ว +1

    I have a bug where if I walk into a wall from any side it teleports me one tile into the wall, i checked my code and i have exactly to code from the video. can anyone explain this? I think it might be an update that changed this, but idk.

    • @stinker-frog
      @stinker-frog 4 ปีที่แล้ว +1

      bruh i did it i was just dumb and didn't delete the code that he says to delete at 9:48

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

      @@stinker-frog I seem to phase through diagonal walls. sometimes I get teleported to the other side

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

      @@stinker-frog I deleted that and it still only collides when going right or down.Did u fix it?

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

    you sir, are an angel

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

    How can I change this to work with a sprite mask? I like the collision but only being able to detect one pixel makes my player feel like a piece of paper

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

    If you're used to object collisions, using the sprite's origin as the point of contact with the tilemap collisions (as oppose to the sprite's collision mask) could look weird at first (as though you are moving too far in to the red collision box). But once you put graphics in to the game and turn off the red box's visibility it looks pretty awesome. Just my opinion.

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

    Small thing:
    Is there a way to stop the computer from typing over the whole line? If I make an error and try to correct it, it’ll start typing over existing words without making space for the new words I’m typing
    Does that make any sense?

    • @Leo-oo2cv
      @Leo-oo2cv 3 ปีที่แล้ว +1

      if you haven't already figured it out, press the "ins"/insert button on your keyboard

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

    the first square is left blank because the first square is the erase or the nothingness. same as when you look at the colors the first square is the nothingness block.

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

    Hi Shaun, whenever I try to make a create or step event it won't let me type in it and it also has a lot of random boxes on the right side that are related to making things move and stuff. Could you please help me to get it like yours?

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

      Axodia left click on it and click convert to gml

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

    Seem to have an issue where if I delete tiles I still get random collisions on them. Not sure if this is a common glitch?