How do I make player moving until hit wall?

0 favourites
  • 2 posts
From the Asset Store
12 unique hits, slashes and spells in transparent PNG sequences
  • Hi,

    I want to make game like this:

    • all levels are made from blocks
    • some blocks are walls
    • player can move up, down, left, right but only when he is not moving
    • player will stop when hit wall
    • player must always stop exactly at the center of block

    Currently it is done by 8 way direction and collisions with solid blocks. But it is bad, move is weird, it stops randomly before hits wall and player can't fit into narrow road.


    What is better solution?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Looks pretty good already!

    The problem that you're encountering are collision polygons.

    Since your game is highly dependent on collisions, it's important that the collision polygon of your player fits exactly between two obstacle blocks and that the shape is the same.

    To achieve this, you'll have to look at the size of your player and your obstacles.


    If an obstacle is 50 x 50 pixels, your player collision polygon must not be bigger than 48 x 48 pixels.

    (If it was 50 x 50 or 49 x 49, it would not fit between two obstacles)

    And you will also have to make sure that both the obstacle and player collision polygon's dimensions are 1:1 (=quadratic).

    Here is a .capx demonstrating what I mentioned. Note how the player is 48x48 and the tilemap obstacles 50x50.

    Hope this helps.

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