Auto Populated Tilesource Collisions (SOLVED)

#1

Hello,

I hope that everyone is doing well. It has been a while since I have last been on this forum, my studies started back up and my time has been diverted. I am making an effort to get back involved though.

My question is in regards to the auto-populated collisions the tilesources create. Is there any way to make them more precise? (screenshot below)

Thanks for any insight!

All the best,
V

2 Likes

#2

Instead of using the colorful tiles as the source for collision, make a solid color version of the tiles and use that for generating the collisions to better control how they are automatically generated.

4 Likes

#3

I don’t know if I managed to understand well
I mean use something like that to calculate the area of the collisions:

+

Instead of this?

0 Likes

#4

Similar to that yes. What I mean exactly is you make a copy of your tiles image, then make a layer above the colorful tiles which are solid colors. Then you edit the pixels of this layer to adjust the auto-generated collision shape. Then you select this image instead of the colorful tiles image.

2020-10-08%2000_49_34-Auto%20Populated%20Tilesource%20Collisions%20-%20Questions%20-%20Defold%20game%20engine%20forum

This could be an example of the collision tile image. Then you just add/remove tiles to get the auto-generated collision shape that you want.

3 Likes

#5

Thanks for the answer ^^

1 Like

#6

This makes sense, thanks for the help!

1 Like

#7

Hello,

I’m not sure if I did something wrong but here is how I have it set up.

In the sile source under image I have :

Under collision I have :

Alas, there are still inconsistencies with the collisions on the slanted pieces as seen here:

Any insight would be greatly appreciated! Thanks!

Best,
V

(The first tileset image is for internal use only, please do not download or save.)

0 Likes

#8

Let’s ask @JCash tomorrow!

1 Like

#9

Edit the collision image (mask away areas) until the shapes generated are closer to what you want, the point is that their alpha is not the same as the color tiles. It will take some aggressive masking / trial and error to get what you want but it should still be possible to get something closer to what you want in this way.

0 Likes

#10

While the collision tile generation code tries to be helpful, it sometimes doesn’t produce great results.

We use a simple rubberband algorithm to create the convex hull.
This particular implementation fits 16 evenly rotated planes as closely as possible around the image. It is written this way to favor certain slopes of the generated shape (e.g. 0, 45 and 90 degrees)

Bearing this in mind, you can change the shape of your collision to use the 16 different slopes.

3 Likes

#11

I think that there is a chance I am doing something inherently wrong because this is now what my collision image looks like:


And the results remain exactly the same…
At this point, I would continue masking away the slopes but there is almost nothing left haha!
Are there any other tile collision solutions I may be able to take advantage of?

0 Likes

#12

By applying a layer stroke in Photoshop it is evident that there are stray pixels which are causing problems in the automatic generation. To avoid issues like this, I recommend using a tool like the polygon lasso tool and rectangle marquee tool to make clear cut selections on their own layer above your art layer to make a layer suitable to adjust for collision shape generation. Then as you carve out areas of your mask make sure it’s with these harsh tools and not a paint brush. It will still take experimentation on the shapes to get the generated result that you want.

It you set the grid size in Photoshop and make it visible it can make it easier to snap to sizes you want. Other art tools probably have similar features.

5 Likes

#13

Wow, thank you so much for taking the time in photoshop to illustrate what the issue was, I really appreciate it!

I will definitely toss the image back into photoshop and take a closer look!
I’m sure it’ll work this time, thanks so much!

Best,
V

3 Likes