About the "Add Tilemap Collisions" Extension

This extension adds the behavior of automatically placing tilemap collision objects to your game.

What's new in version 0.5.0

  • Collisions on all visible layers are now covered.
  • If the tile is rotated or flipped, the collision object will also be rotated or flipped.
  • Added "Auto Add" feature.

What's new in version 0.4.0

It is now possible to get the ID and collision name of the tile at the coordinates.

This allows you to know which tile is at the coordinates without having to generate alternate collision objects.

"Conditions" and "Expressions" have been added for that purpose.

These are useful in JRPG etc.

Features

The objects will be merged into a rectangle.

How to use this behavior

Import the "AddTilemapCollisionsExtension0.0.0.json" file that you downloaded into your game.

In the Tile Collision Editor of Tiled, add a collision to the tile and name it. You can make different tiles eligible for merging by giving them the same name.

Only the first collision object is valid. The shape of the collision object is ignored.

You should create an object (e.g., Sprite) with the same name as your tile collision in GDevelop.


You can add "Platform behavior", "Physics2 behavior", etc. to that object as needed.

The Tiled collision shape is ignored, but GDevelop's collision mask can be used instead. However, you need to be careful that it does not get merged. (Sprites with custom collision masks will not merge.)


Adds the "Add Tilemap Collisions" behavior to the tilemap object.


If you have the behavior's "Auto Add" parameter disabled, add an event to generate alternate collision objects for the tile map.

Tile maps with added behaviors will start the parsing and merging process as soon as the scene is started. In most cases, the process is instantaneous, but if the tilemap is complex, it may require some time.

So, use the conditions that are provided to check if the process is complete.

Launch the preview and check that the alternative collision objects are generated correctly 😉
(The objects (instances) is hidden.)

Advanced usage

For example, you can identify them in the game by giving the stone platform and the ice platform different collision names.

The generated object does not necessarily have to be an obstacle. For example, in the demo on this page, objects are generated in the flower area to check if the player is touching the flower.

If you just want to get the ID and collision name of the tile at the coordinates, you don't need to prepare an alternate collision object and perform the "Add Collision Objects" action.

Unsupported

This extension may support these features in the future.

  • External tileset. Supported!
  • Tile Layer Formats other than CSV.
  • Infinite map size.
  • Even if tiles are rotated or flipped, collisions are not generated in a rotated or flipped state. Supported!
  • Features not supported by the tile map object.

Supplementary information

Apparently, a more advanced tilemap collision feature, separate from this extension, is being prepared by GDevelop officials. You may want to wait for it to be released. (It is unknown when it will be released. As of December 2021.)

When it is released, I will try to investigate the differences between it and this extension.

Tilemap collision mask has been implemented in GDevelop 5.0.139.
However, it cannot get tile IDs, etc. from coordinates.
It also does not allow for custom collision masks.

This extension is in beta.

StatusIn development
CategoryOther
PlatformsHTML5
Rating
Rated 5.0 out of 5 stars
(1 total ratings)
AuthorPANDAKO
Made withGDevelop, PixiJS
Code licenseMIT License
LanguagesEnglish

Download

Download NowName your own price

Click download now to get access to the following files:

AddTilemapCollisionsExtension0.5.0.zip 5 kB
AddTilemapCollisionsExtensionExamples0.5.0.zip 44 kB
if you pay $5 USD or more

Development log

Comments

Log in with itch.io to leave a comment.

@pandako, @community, I have a really elementary question, I am really new to the world of tilemaps, so kindly excuse my ignorance. Can I give different names to tiles that together form a terrain object and expect the same kind of collision handling?

Although a tilemap collision mask object has been implemented in GDevelop 5.0.139, your extension works way better for me. I was having an issue with lateral collisions where sometimes the player slides one pixel inside the GDevelop collision mask object, although it never happened when colliding with platform sprites. The gameplay felt unpolished because of that. With your extension, my problem was solved because it allows me to use a sprite with platform behaviour as a hitbox, so the collision issues are gone. 

You did a great job developing this extension! It made everything easier for me to make my game. 

Hey Pandako, I believe you will have to update. According to my tests here in the next version, this extension stops working.

Even if I change it to (0,1,2,3,4...) nothing works.

And when adding BEHAVIOR, those numbers that are there appear.


(+1)

HI,

I still can't get the next version (v5.0.141?). I will check the behavior as soon as the next version is released.

Thank you for telling me.

It's just that I do tests of Builds that will be released and so I look for bugs and other things, and when I saw this bug I decided to let you know.. However. If you are going to modify the code, would it be possible for you to add a way to generate the objects through the layer name (the tiled) instead of the Number?

I too wish I could use layer names.
However, using layer names is problematic in several ways.

  1. Names can be duplicated.
  2. Names can be empty.
  3. There must be separate input fields for the layer number and the layer name.

At the moment I do not have a good idea to solve these problems. 😥

Hey PANDAKO, I made an extension using parts of your extension. It turned out really good. If you are interested in testing and contact me on Discord. willianholtz#6880

I also couldn't get it working properly on the latest version of GDevelop -  this extension would be an absolute lifesaver if I could get it running!

I have confirmed that this extension works correctly with GDevelop 5.0.140. Did it work correctly in previous versions?
I need more information on this.

(1 edit)

I haven't tried it before no, but I followed your guide as closely as I could and still couldn't make it work. My character fell through even though I made sure to run the event at the beginning to autofill the tilemap, I made sure that behavior was applied, had my Collision tiles marked and gave the objects the platform behavior. I could try it again but I sincerely don't know where I went wrong if there was a mistake on my part somewhere

(+1)

Here are the notes I can think of right now

Note that this extension differs from the "Tilemap Collision Mask" added in GDevelop 5.0.139 in the way "Tiled" is set.

The "Tile Layer Formats" of the tilemap file must be CSV.

Is the "Layer Index" value you set for the behavior correct?

Does the GDevelop debugger show any warnings or errors?

- yes, I checked and it's just the usual Tilemap, not a collision mask

- I double checked, it should be CSV

- I'm not 100% sure about that? should it be on layer 0?

- I got a "Not yet ready to generate a collision!" error in the debugger, not sure what that means

"Not yet ready to generate a collision!"

This message will appear if you run the "GenerateCollision" action before the parsing and merging process is complete.

Try using the "isReady" condition as shown in the image in the documentation.

Hello, I tested this extension today and it was working 100%, however, now it doesn't work anymore, I have no idea why! It just stopped creating collisions!

gDevelop  5.0.129

(+1)

Hi,

Thanks for letting me know.

If I see it working with 5.0.129, I'll let you know here.

I believe it has something to do with Tiled's json. In my version (Linux) it has two types of json, version 1.1 and the current one. I was using 1.1, before gdevelop updated and only today I noticed that Tiled's .json version had also changed! So I deleted all cached folders and everything else from the two apps, and it works again!

Is there any possibility to use more than one layer to create collisions? As well as Tiled objects?

I have verified that this extension works correctly with GDevelop 5.0.130.

The version of Tiled I was using was 1.7.2. I have upgraded Tiled and verified that it works correctly with 1.8.2.

Unfortunately, I have no plans to add the ability to generate collisions from multiple layers at this time.

However, if many users request it, we will consider it. Please post here if you would like to have this feature.

Deleted 1 year ago