How do I get collisions working on a tilemap?

Get help using Construct 2

Post » Thu May 22, 2014 11:38 pm

I am working on a game that uses a tilemap of 32x32 tiles. It uses a Pacman-esque "maze", and the player is also 32x32. Player collisions with the map are not working at all unless I give the tilemap object the Solid behavior. However, this doesn't work as intended - it pushes the player all the way up to the top right tile, and won't allow movement (I suspect because the player is touching collision tiles in the map being that he's 32x32 and only has pathways of 32x32 tiles that are not collision tiles, so if the player is in a vertical tunnel, he's touching walls on either side).

Is there a way to make a tilemap collidable where it's a perfectly tight fit for the player, without having it push the player around?

Here's a demo I made using Phaser.js which demonstrates how the movement and collisions SHOULD work: http://games.clowerweb.com/games/thundercastle2/

And attached is a .capx demonstrating what happens when I try to do the same in Construct.

(In case you're wondering why I'm doing it in Construct after having already made so much progress using Phaser.js, it's because I'm trying out various engines/frameworks and methods of game creation to see which works the best for me.)

As a side note, you may also notice that the Pin behavior that's on the PlayerArmor sprite isn't working with 8-direction controls (though, funnily enough, it works perfectly when I use Keyboard Keydown events). If you also know why that is, it would be greatly appreciated if you could answer that one too.
You do not have the required permissions to view the files attached to this post.
B
15
S
4
G
4
Posts: 11
Reputation: 3,488

Post » Fri May 23, 2014 8:15 am

The only mistake is assuming that a 32 by 32 character can move in a 32 by 32 gap. If you think about it, the edges are exactly aligned, therefore causing a collision event.

If you make the gap 1 pixel either side wider, or make the player 30 by 30, then it will work as intended.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,393
Reputation: 58,468

Post » Fri May 23, 2014 4:18 pm

zenox98 wrote:The only mistake is assuming that a 32 by 32 character can move in a 32 by 32 gap. If you think about it, the edges are exactly aligned, therefore causing a collision event.

If you make the gap 1 pixel either side wider, or make the player 30 by 30, then it will work as intended.


It doesn't work as intended, because then there's 1px of wiggle room on each side of the player. Tile-based games work on the principle of the tiles and sprites being the same size, thus the player being 1 tile wide and 1 tile tall, and moving in spaces that are 1 tile wide/tall. The grid is intended to be perfectly tight, I just don't want the collision objects pushing the player away from them. In Phaser, a collision is only detected when the player is actively trying to move into the collision object. You can stand against it all you want and it doesn't push you out. This is the behavior I need to get in Construct if possible by removing the "push out" behavior of collisions or something similar.
B
15
S
4
G
4
Posts: 11
Reputation: 3,488

Post » Sun May 25, 2014 2:05 am

Bump. Anyone?
B
15
S
4
G
4
Posts: 11
Reputation: 3,488

Post » Sun May 25, 2014 8:02 am

The following thread, especially the responses from Christine and Ashley may be helpful.

https://www.scirra.com/forum/solved-pixel-perfect-platform-engine-using-loops_p664644?#p664644

If not, then maybe post a minimal project with step by step instructions in the Bugs section.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,393
Reputation: 58,468


Return to How do I....?

Who is online

Users browsing this forum: amazingdream and 22 guests