How to implement SAT for Tilemap?

1 favourites
  • 3 posts
From the Asset Store
This is a black tileset with 2 tilemaps, props, one animated character and more.
  • Hi, some time ago R0J0hound posted a great thing:

    https://www.dropbox.com/s/29oqa2k7o1c6x ... .capx?dl=0

    A test to keep multiple moving sprites from overlapping each other or overlapping the walls. The wall collision resolution is done with the separating axis theorem (SAT) which has the benefit of allowing the sprites to smoothly slide accross the walls. The motion is done with verlet intergration which when used with a way to push out of obsticles provides for decent boncing.

    Will this work with Tilemap? And if so, how to get BBoxRight/Left/Top/Bottom from each tile?

    Tagged:

  • The tilemap has some expressions you can use to get that. Namely the row and column of the tile at a certain xy. Then you can use another expression to get the xy of the tile at a certain column and row. That will give you the tiles center then you can get the sides by adding/subtracting half the tile width/height.

    But you can calculate all that directly. For example if the tilemap is at 0,0 with a 32x32 tile size, and the player objects are smaller than 32x32, then this will give you the bounding boxes of each of the tiles the player could be overlapping.

    Gridx= int(player.x/32)

    Gridy=int(player.y/32)

    For i=-1 to 1

    For j=-1 to 1

    Tile at (gridx+i,gridy+j) != -1

    — left = (gridx+i)*32-32

    — right=(gridx+i)*32

    — top=(gridy+j)*32-32

    — bottom=(gridy+j)*32

    — resolve collision

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0J0hound Thanks mate!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)