How to do tiled movement tht respects solid collision layer?

0 favourites
  • 2 posts
From the Asset Store
Piano tiles
$9.99 USD
Template for a piano tiles game, fully documented in comments and video
  • I want my character to move on a grid. I've found two decent methods of doing this, as seen in this screenshot:

    Either I set an angle and 'move the character forward' as many pixels, or I use 'Set X' and 'Set Y'.

    Obviously there's no reason to mix-and-match like this, just showing I've tried both.

    The problem is that neither of them respect the 'solid' parts of my collision layer! So I have a ghostly player character just floating through walls.

    There's gotta be a fairly simple/elegant solution to this...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use a tilemap, with tiles that equal the size of the player and throw a solid behaviour on it.

    Then you can store the player tile position and use that to check vs collision.

    So if

    player.Tile_X = 5

    player.Tile_Y = 5

    And the player press Right key to move to the right, you can do a tilemap comparison, so:

    Tilemap.compareTileAt Player.Tile_X + 1, Player.Tile_Y not equal 0 --- (If that is the tile you use as collision)

    ....If that is not the case, you just increase the Player.Tile_X by 1 and convert the Tile position to a pixel value position (standard X,Y)

    And you can do that for up and down as well, just by increasing or decreasing the Tile_Y variable.

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