0 Favourites

How do I make player moving until hit wall?

  • 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.

    Example: https://youtu.be/56nCJPujoa4

    What is better solution?

  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic
564 105,191
rexrainbow's avatar
Unread hot topic
167 14,489
DMT2005's avatar
Unread hot topic
0 Favourites
[plugin] Youtube player
175 20,538
rexrainbow's avatar