How do I make collisions with grid movement?

0 favourites
  • 7 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • I want the player sprite to have grid movement but still be able to collide with walls. I got it to work by offsetting the collision box by 1 but now pinning objects to each other when they collide doesn't. Is there a better solution for collisions?



  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I can think of two options -

    1. Use "Overlapping at offset" to check if it's safe to move in the selected direction on the grid. You have to repeat this check for the main Player sprite and for all connected parts.

    2. Completely different approach - use a tilemap object as a Player. So each time you need to add a new piece to the player, instead of pinning it, add it as tiles to the tilemap. Tilemap is the only object in Construct which allows to modify its collision mask.

  • I tried the first option but it doesn't work unless I make the collision box smaller which prevents the pin from working.

    The problem is showcased in this video

    How would I get the game to move to the next layout when the player sprite and connected parts overlap exactly with another sprite?

  • You can make the collision polygons 1px smaller. To pin a neighboring sprite you'll have to again check for "overlapping on offset" instead of using "on collision".

    So when the player arrived to a new position, check if it's overlapping at a small offset (say 2 pixels) any new pieces in four direction. If it does, pin these pieces to the player.

    Answering your second question - you can put small invisible sprites in the center of each cell in the target area. When all these sprites are overlapping the player will mean that the level is completed.

  • I tried changing "on collision" to "overlapping on offset" after making the collision polygons 1 pixel smaller but it didn't work as intended. I set the offset to 2 pixels and it made the sprites pin in weird ways. Can you show me how this would work?


    C2 has so many quirks - with Pin, OR-blocks.. This would be much easier to make in C3 using hierarchy.

  • That's the previous project I was working on but the collisions are working properly.


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