# How do I correctly make collisions for tiles?

0 favourites
• 4 posts
From the Asset Store
Piano tiles
\$9.99 USD
Template for a piano tiles game, fully documented in comments and video
• I will provide a screenshot of my initial problem so visual evidence can help you guys understand the issue here

Screenshot : imgur.com/53M8t4H (had no idea how to upload an image right to the post sorry!)

Well, I've literally only started out with this engine after getting a bit bored of Stencyl and this engine looks great already I've been through the basic tutorials and read some other learning documentation before I decided to just have some fun and place random stuff within a layout so I can learn interaction a bit better.

Anyways, I pulled in a Pokémon tilemap and right away came across the issue that I had no idea how to solve, making specific tiles have a collider so my player couldn't just walk through it e.g. trees, houses and I decided just to add another tilemap identical to the original and create a solid behaviour so I could use that tilemap for any collision I needed for tiles and the player.

After, I noticed it was successful, but not perfect D: as the print screen shows, the collision is not the greatest, as for example if I wanted to walk into that house, I am only limited to go as far as the image shows before collision stops my movement, yet I can walk to the side of the house perfectly. Placing two houses near-ish together makes it impossible to get anywhere near the front of the house and well, I would just like to know how could I make it so my character could walk right up to the door, or better yet;

any chance I can customise the collision bounds for specific tiles within a tile map? I have no idea, and not sure if this seems clear but I think using "solid" behaviour applied to a tilemap doesn't seem to be the most effective way, unless of course I am doing it wrong

Thank you.

• Hi, yes you can easily draw in the collision around any object. Double click the sprite to open the editor, and then hit the bottom left icon (Set collision polygon). Here you can add points/vertices to create collision shapes. This collision map will then apply to every instance of that object i.e. every house

• Hi, yes you can easily draw in the collision around any object. Double click the sprite to open the editor, and then hit the bottom left icon (Set collision polygon). Here you can add points/vertices to create collision shapes. This collision map will then apply to every instance of that object i.e. every house

Hello, thank you so much for the guidance and reference, however I did try to use this option before posting and I noticed that the collision points were not working, I dunno what it could be perhaps I might've put them on different layers; however I should've been more persistent in accomplishing this task before posting as I made a little fix for myself; I simply made a 32x32 invisible tile that was solid and placed them wherever I needed invisibly onto whatever places I wanted more accurate collision detection.

As I previously said, thank you for your time and effort to help me!

• ## Try Construct 3

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

Construct 3 users don't see these ads
• You can easily set the collision polygon for a tilemap object.

Excerpt from the manual -

"When testing for collisions with a Tilemap object, empty (erased) tiles count as not colliding, and all other tiles count as colliding. A custom collision polygon can be set for individual tiles by clicking the 'Edit tile collision polygon' button in the Tilemap bar, or just double-clicking the tile in the Tilemap bar. Note however the collision polygon cannot be entirely removed from a tile: only an erased tile counts as not colliding at all.

If you wish to have tiles that are visible but do not register a collision, use two Tilemap objects layered on top of each other. Test for collisions with just the top object, and erase any tiles that should not register a collision. These tiles can then be placed on the tilemap object beneath, so they appear in the same place but are not tested for collisions."

When you have set the collision polygon for the tilemap, check the collision polygon for the character as well, as C2 likes to estimate it on import. Squares really work the best, if you don't need per pixel collisions.

If you need more help, you can post your capx and we can take a look at where things are going awry.

• 4 posts