• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help getting started with Essential Autowall 2

binarypearl

Member
Looks like I should have placed this under the 'Marketplace' category, sorry!

I'm trying in my 2D platformer to use tilesets with collision to define wall boundaries and platforms. I got 'Essentail Autowall 2' on the Marketplace. I was able to import it and get it to draw tiles with both Instances/Objects and Tiles, but am confused on two different areas:

1. Neither Instances/Objects or Tiles were detecting any collision, so my objects (playable characters, projectiles, etc) went right through them. Do I need to include my own wall objects with a collision mask, or is there a way to do that with Essential Autowall 2?

2. In what situations would I want to use Instances/Objects vs what situations would I want to use Tiles?

(Hopefully I got the terminology correct with Instances/Objects vs Tiles)

Thanks!
 
Last edited:

Yal

šŸ§ *penguin noises*
GMC Elder
My educated guess (i haven't used this asset) is that it only does exactly what it says on the tin: generates wall tiles automatically. Collisions are much more game-specific so it wouldn't make sense to include code for that in the asset. (E.g. the asset can be used both for top-down and platformer games as is, it would be less useful if it had platformer-specific collision code in it)

Tiles don't have collision checking on their own, but you can check this manually with varying degrees of complexity. For instance, I like an approach where tiles up to <certain constant> e.g. the first 256 pixels horizontally are solid, and anything further to the right is a decoration without collision:
GML:
function pixel_walkable(xx, yy) {
    var lay_id = layer_get_id("tile_bg");
    var map_id = layer_tilemap_get_id(lay_id);
    var mx = tilemap_get_cell_x_at_pixel(map_id, xx, yy);
    var my = tilemap_get_cell_y_at_pixel(map_id, xx, yy);
    var data = tilemap_get(map_id, mx, my);
    var ind = tile_get_index(data);
    if(ind > 0){
        //Tile existed (note that index 0 is reserved as the "erase" tile so it's invalid)
        var column = ind mod TILEROWS_TOTAL;
        if(column < TILEROWS_WALKABLE){
            //This tile is walkable
            return true;
        }
        else{
            //This tile is solid
            return false;
        }
    }
    else{
        //No tile - this is offscreen or the void or somesuch
        return false
    }
}
If you want slopes and other non-binary collision, you can extend this approach to check for a "tile type" based on its position in the tile set, and run different code (e.g. point_in_triangle) to check the region that matters for that tile type:
tileset_cave.png

Tiles are much faster to process and draw than object instances (an instance is the actual thing, an object is the blueprint that is used to construct them - this terminology is confusing as heck from an intuitive sense, most languages call them Objects and Classes instead), especially when you have a lot of them, so ideally you want to use tiles whenever possible for terrain stuff that doesn't move. Objects is the only option if you have moving platforms, and they're arguably easier for desctructible terrain as well (though you can do that with tiles if you really need to)
 

binarypearl

Member
Thanks all for replying! It looks like I'll need to add a separate collision detection. I'll take a look at the tile collision example above. I saw another concept of using separate objects of same size under the tiles to detect for collision. That works but it's dual maintenance which I prefer to avoid if possible.
 
Top