How do I make player moving until hit wall?

Get help using Construct 2

Post » Fri May 12, 2017 6:03 pm


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?
Posts: 8
Reputation: 241

Post » Fri May 12, 2017 6:19 pm

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.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
Posts: 528
Reputation: 7,091

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests