I've always resisted the move to tilemap collisions (growing up on object collisions and all), but this video makes it look pretty easy. I think it's worth a shot. Thank you.
I mean... Why wouldn't you try and collide with tiles? Even Unity, being a 3d Engine, unlike Game maker, collides with 2d Tilesets efficiently. It's a shame that Game Maker doesn't provide an easier, more streamlined option for this, which is probably why the community said fuck this engine.
Well, a gane maker object has like 50 built-in variables, alarms, checks and stuff going on every step. Why would you need your walls to check for all those with every instance of platform you have? On the efficiency side, there's just no comparaison. Since 2.3, I almost pretty much just use 1 or 2 actual objects, the rest being structs. It does save a lot of power, try it.
This script looks a bit easier to follow. The other ones are going all hard on the math, which isn't a bad thing, but for idiots like me, it is. and what snipped I saw in the video didn't look too tough to dissect and learn from. I want to use Tile-based collisions on my next project in GMS 2.3 after I finish my 2.2.5 project, because my current method of using object collisions do feel quite sloppy.
I have no idea how to get jumping to work, as all jump tutorials reference an object to check for collissions on (like an obj_wall as an example). How do you implement jumping that also detects the collisions on the tilemap?
if tilemap_get_at_pixel(tiles,oPlayer.x,oPlayer.bbox_bottom-1) == 0 and keyboard_check_pressed(vk_space) { VerticalSpeed = -PlayerJumpForce } or if tilemap_get_at_pixel(tiles,oPlayer.x,oPlayer.bbox_bottom-1) == 0 { OnGround = 0 } else {OnGround = 1} and then you're already doing a jump check. Is it really that difficult?
Hey do you know what I did wrong with this code? As of right now all it does is either not work or crash my game // Top Collisons if (tilemap_get_at_pixel(tiles, bbox_bottom + ySpeed, x) != 0) { y = round(y); while(tilemap_get_at_pixel(tiles, bbox_bottom, x) == 0) { y -= 1; } while(tilemap_get_at_pixel (tiles, bbox_bottom, x) != 0) { y += 1; }
It is vary much possible it just is a pain in the butt. one way is to load all of the tile set in a room before hand have it iterate through it to determine what is actual tile and what is empty space. because by default it considers all of a tile even if parts of it are transparent. best way to do it is to have a collision tileset that is super simple that has all the curves slopes and what not you need store what is real space in some kind of matrix and reference that later
//I'm using this for the down collider if(tilemap_get_at_pixel(tiles, x, bbox_bottom + speedY) != 0) { y = round(y) while (tilemap_get_at_pixel(tiles, x, bbox_bottom) != 0) y -= 1 while (tilemap_get_at_pixel(tiles, x, bbox_bottom) == 0) y += 1 speedY = 0 }
"layer_tilemap_get_id" only runs once at the creation of the object. How does "tilemap_get_at_pixel" use tiles as an argument if it is always the same element of a tile map?
the tilemap_get_id is stored inside a variable which has the room tiles, aka tilemap. tilemap_get_at_pixel format is (tilemap, x, y) that checks what tile the point at x, y is touching on tilemap [tilemap]. if its 0, it means theres no tile at the point
Ok i figured out the jumping issue but now the top collisions don't work. My character just clips through the platform and warps outside it. Can you show the code you used for vertical collisions in your example
You know what, I'm having a hard time finding them, too. You can check out this link for some that are pretty similar. If I find the specific tiles, I'll definitely link them for you. opengameart.org/art-search?keys=platformer
@@LetsLearnThisTogether I'm trying to collide with a specific tile, just not the whole tileset, so it's a little more complicated on my end. I'm about to just go back to object collisions because this just isn't working for me
@@LetsLearnThisTogether I ended up getting some help designing a solution that works like position_meeting but for tiles, so I can just reuse my object collision code for the most part. Thank you though!! I appreciate the quick responses
I've always resisted the move to tilemap collisions (growing up on object collisions and all), but this video makes it look pretty easy. I think it's worth a shot. Thank you.
I mean... Why wouldn't you try and collide with tiles? Even Unity, being a 3d Engine, unlike Game maker, collides with 2d Tilesets efficiently.
It's a shame that Game Maker doesn't provide an easier, more streamlined option for this, which is probably why the community said fuck this engine.
Well, a gane maker object has like 50 built-in variables, alarms, checks and stuff going on every step. Why would you need your walls to check for all those with every instance of platform you have? On the efficiency side, there's just no comparaison.
Since 2.3, I almost pretty much just use 1 or 2 actual objects, the rest being structs. It does save a lot of power, try it.
This script looks a bit easier to follow. The other ones are going all hard on the math, which isn't a bad thing, but for idiots like me, it is. and what snipped I saw in the video didn't look too tough to dissect and learn from. I want to use Tile-based collisions on my next project in GMS 2.3 after I finish my 2.2.5 project, because my current method of using object collisions do feel quite sloppy.
I have no idea how to get jumping to work, as all jump tutorials reference an object to check for collissions on (like an obj_wall as an example). How do you implement jumping that also detects the collisions on the tilemap?
if tilemap_get_at_pixel(tiles,oPlayer.x,oPlayer.bbox_bottom-1) == 0 and keyboard_check_pressed(vk_space)
{
VerticalSpeed = -PlayerJumpForce
}
or
if tilemap_get_at_pixel(tiles,oPlayer.x,oPlayer.bbox_bottom-1) == 0
{
OnGround = 0
} else {OnGround = 1}
and then you're already doing a jump check. Is it really that difficult?
It took a while to fix it up in a way for me to personally understand, but it worked out great in the end, thanks!
Thanks! I like this short quick format. I also appreciate a video on tilemaps, we need more of these.
Congratulations Joseph! You've won the free beginner course giveaway! Please email me at aaron@letslearnthistogether.com to claim your coupon code 😄
Thanks! I will for sure buy your course on my next paycheck.
Awesome stuff, checking out your website!
Hey do you know what I did wrong with this code? As of right now all it does is either not work or crash my game
// Top Collisons
if (tilemap_get_at_pixel(tiles, bbox_bottom + ySpeed, x) != 0) {
y = round(y);
while(tilemap_get_at_pixel(tiles, bbox_bottom, x) == 0) {
y -= 1;
}
while(tilemap_get_at_pixel (tiles, bbox_bottom, x) != 0) {
y += 1;
}
ySpeed = 0
}
I'm struggling on figuring out how to detect the numbers it generates. Do you know how to help?
I’m not totally sure, can you elaborate on the problem? You mean specifically on finding the number of the tile set you’re colliding with?
In place of "mouse", I should I put?
I want to collide my obj_player with the tileset...
I know this is a necro post, but you ca try doing obj_player.x,obj_player.y
Is it possible to do ramps/hills using the tile collisions?
I’m sure it is possible, although I’ve not done it personally.
It is vary much possible it just is a pain in the butt. one way is to load all of the tile set in a room before hand have it iterate through it to determine what is actual tile and what is empty space. because by default it considers all of a tile even if parts of it are transparent. best way to do it is to have a collision tileset that is super simple that has all the curves slopes and what not you need store what is real space in some kind of matrix and reference that later
In your project near the end of the video, how could you change the //Left Collision and //Right Collision to be used Vertically. I'm new
//I'm using this for the down collider
if(tilemap_get_at_pixel(tiles, x, bbox_bottom + speedY) != 0)
{
y = round(y)
while (tilemap_get_at_pixel(tiles, x, bbox_bottom) != 0)
y -= 1
while (tilemap_get_at_pixel(tiles, x, bbox_bottom) == 0)
y += 1
speedY = 0
}
"layer_tilemap_get_id" only runs once at the creation of the object. How does "tilemap_get_at_pixel" use tiles as an argument if it is always the same element of a tile map?
the tilemap_get_id is stored inside a variable which has the room tiles, aka tilemap. tilemap_get_at_pixel format is (tilemap, x, y) that checks what tile the point at x, y is touching on tilemap [tilemap]. if its 0, it means theres no tile at the point
Damn that makes collisions a lot more simple
How would this work if you did this vertically?
so i tried to use your tile collision code for your left collision, but when use it somehow my game freezes, you know what the issue might be?
I used the same code for the vertical collision and now my character won't jump anymore. Did you figure out a way to fix this?
Ok i figured out the jumping issue but now the top collisions don't work. My character just clips through the platform and warps outside it. Can you show the code you used for vertical collisions in your example
I suggest you download the Windy Woods template from GameMaker, they have tile collision in there that works way better than what I’ve got.
Is there a pattern to how the tilesets are given their ids?
Thank you so much
Is possible to edit the terrain using tiles? like moving a box or digging in sand
Yeah. There’s so much you can do with tiles in the game it’s crazy.
It gives me the error "create at line 4 cannot set a cobstant to a value" any help?
yea i got that also
How can I make a passable platform out of tileset?
THXXX broooooooo!
Hi :) Can I ask where did you get those super cute tiles? I tried to find them but couldn't
You know what, I'm having a hard time finding them, too. You can check out this link for some that are pretty similar. If I find the specific tiles, I'll definitely link them for you.
opengameart.org/art-search?keys=platformer
@@LetsLearnThisTogether Thank you very much :) I checked there but maybe I missed them.
There are some that are similar, but none exact.
for some reason my character won't jump anymore. any way to fix it?
You might inside of the floor, triggering your collision code. Check that you’re not in a tile or floor
@@LetsLearnThisTogether alright
how you can implement jumping with this code?
I am working on that myself, as it was a little more complex than I thought.
do slopes work?
can you make one in dnd?
I think it could be done, I’ll check it out.
Can you make a complete video of the tutorial? Can not understand anything.
is the mouse a character
No, but GameMaker does track where it is at all times.
Not working for me. My character goes into the tile then zips to the other side.
That’s a common problem. It usually means a small typo in the while loop. Download my project and compare it to yours. You’ll find it there.
@@LetsLearnThisTogether I'm trying to collide with a specific tile, just not the whole tileset, so it's a little more complicated on my end. I'm about to just go back to object collisions because this just isn't working for me
Tile collisions are tough.. I plan on adding some more videos soon. Can you explain what you’re doing and why? I may make a video on it.
@@LetsLearnThisTogether I ended up getting some help designing a solution that works like position_meeting but for tiles, so I can just reuse my object collision code for the most part. Thank you though!! I appreciate the quick responses
@@LetsLearnThisTogether I know this is 3 months ago but I cannot find the link for downloading your project :(
How to destroy a tile in a specific location?
I think this is what you want: docs2.yoyogames.com/index.html?page=source%2F_build%2Findex.html
it didint work help
didnt work, pls help
i dont like using object collisions such a pain for parts of the world. way better for things in the world.
too complicated °^^