1
\$\begingroup\$

My floor tile is a 2D drawing of a 3D platform, for lack of a better description. I want my player character to stand not on the top of the tile but a little inside it, as the red circle does in the picture.

enter image description here

How do I give this tile its own collider that would fit this shape, while letting others have a normal, square one?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

For your colliders on your tiles, reduce the offset from the top of the box. So while it will render the whole image, only part of it will detect collision.

Before:

enter image description here

After:

enter image description here

\$\endgroup\$
9
  • \$\begingroup\$ Yeah, I just tried that, and it seems to work. Do I have to create another tilemap and put other, normal tiles there that would have an offset-less collider? \$\endgroup\$ Oct 16, 2018 at 18:34
  • \$\begingroup\$ Depends on how you are doing your tile sets. Assuming you are 9-slicing it, just change the collision boxes of the top 3 tiles. \$\endgroup\$
    – Evorlor
    Oct 16, 2018 at 18:35
  • \$\begingroup\$ 9-slicing? I'm a total beginner to game development, and this is my 3rd practice project. It's also my first time using tilemaps. So, instead of just up and creating a whole tileset, I created one tile (the one you see on the image), imported it and it alone, and shoved it into the tile palette. I didn't have to slice a large tileset. \$\endgroup\$ Oct 16, 2018 at 18:37
  • \$\begingroup\$ are you using a library/tool/plugin to make your tiles? Or is it just a bunch of GameObjects? \$\endgroup\$
    – Evorlor
    Oct 16, 2018 at 18:41
  • \$\begingroup\$ Just a PNG file I imported into Unity and then dragged into the tile palette window. No plugins or anything. I made the image in Aseprite. \$\endgroup\$ Oct 16, 2018 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .