0
\$\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
\$\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\$
  • \$\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\$ – Demetre Saghliani Oct 16 '18 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 '18 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\$ – Demetre Saghliani Oct 16 '18 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 '18 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\$ – Demetre Saghliani Oct 16 '18 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.