GMS 2 Need help with tilemap for collision (when I create the tileset, it does not show my colored tile)

mizugori

Member
Sorry if this is a dumb question. I am trying to have large curving walls in a scene, and I want collision on them (no objects should be able to pass through them.) At first I tried just putting a huge object, complete with it's own massive sprite, into the room for each wall. However, none of the less resource-intensive collision options are viable, only the "precise" collision mask option will work. (trying to use rectangle, oval, diamond etc. cannot get anywhere close to an accurate outline of the wall shape.) And I have several of these objects, and did I mention they are HUGE.

To make sure we are on the same page, imagine trying to do collision on a wall shaped like this:

curved-wall.jpg

(You can see how it would be difficult to simply apply a collision mask to an object like that blue line.)

I did the Shaun Spaulding ARPG tutorial and he demonstrated using a tilemap for collision. I was thinking this could be a much better way to handle the collision. In his tutorial, he uses a 32x32 image, which he colors the top right 16x16 pixels of. I tried to replicate this, and it worked, but 16x tiles are way too big to get a nice approximation of the curves of the walls.

So I tried making 8x8 or 4x4 size tiles (just yellow squares) for my collision tile, thinking I can draw a much closer map that more closely matches the actual outline of the walls, though it will take forever to paint. However - when I create the tileset and try to paint it onto a tilemap layer in a room, there is no yellow square to be found anywhere...

Here is my sprite / tile:

brush.jpg

Then here is the tileset:
tileset.jpg
*I did try changing in the top right where it says 16x16, I tried making this 8x8, 4x4, etc to no avail*


Here is where you can see it has created that automatic checkered square in the top left that GMS2 does automatically, but there is no yellow square immediately to the right of it as there should be:

tilebrush.jpg

Can anyone tell me what I am doing wrong here? Maybe I am making some silly mistake with the tile, or maybe the whole way I am trying to solve this is stupid and someone has a better idea? I appreciate any advice.
 

EvanSki

Raccoon Jam Host
you need the sprite to be 8x4 but the tile in that sprite be 4x4, tiles require a blank tile for optimization
hereyougo.png

The red will be "removed" for optimization and the yellow will be the first tile
that png is the correct size you need I just stretched it out to make it easier to see here


Read it wrong sorry, thought your tile was 4x4 but its 1 pixel in a 4x4 sprite
Game maker may have a minimum size required for the tile or maybe its just so small you cant see it
 

mizugori

Member
Since you are familiar with Shaun Spalding's tutorials, look up his tutorial on sloped tiles.
I appreciate the thought, I was excited and looked this up, but it appears it is not going to work in my application. This is in a top-down game so there is no "gravity" and there will be plenty of cases where the wall is north of the player. This seems to break all of his code (he even makes a big disclaimer about all the limitations at the beginning, basically each limitation is a requirement for me lol.)

I might revisit doing them as objects and seeing how the performance is with them on precise collision masks...
 

mizugori

Member
I tried everything under the sun. As far as I can tell, GMS2 simply refuses to draw tiles that are less than 16x16. This is just too big for me to work with unfortunately. Does anyone know if that is an actual limitation? I searched extensively but I do not see any other reference to it which seems odd; surely someone else has tried to do a 8x8 tile size before...?

I'm currently playing around with just using the objects with precise collision, but this approach seems incredibly wasteful, I would rather do it with a tilemap if it's possible.
 

Slyddar

Member
I just tested this with an 8x8 tileset, and it worked fine. I then lowered it slowly down to 1x1 and it still was fine, and drew in the room fine. Not sure what I've done differently to you, but everything you've done looks correct, so it might just be a GMS2 glitch. Try restarting GMS2 and just test it in a new project to ensure it actually works there, before doing it again in your game.

tileset.png
 

TheouAegis

Member
I appreciate the thought, I was excited and looked this up, but it appears it is not going to work in my application. This is in a top-down game so there is no "gravity" and there will be plenty of cases where the wall is north of the player. This seems to break all of his code (he even makes a big disclaimer about all the limitations at the beginning, basically each limitation is a requirement for me lol.)

I might revisit doing them as objects and seeing how the performance is with them on precise collision masks...
The difference you'd need to account for is his code only deals with downward direction, so you'd need the height map to account for upward motion as well. Let's call the height map Shaun discusses "floor_map" and the height map you'd need to supplement that with "ceiling_map". So floor_map would count the solid pixels from the bottom of the tile to the top, and ceiling_map would count the solid pixels from the top of the tile to the bottom. When you collide, vertically, pick a point on the sprite to check and then compare it to floor_map if you are moving down, or to ceiling_map if you are moving up. For moving horizontally, you'd need to check both floor_map and ceiling_map if some tiles don't take up the full tile width.
 
Top