1
\$\begingroup\$

I have hand drawn isometric background looked at about 35-40 degrees.

How to set walkable areas at such image?

Is it possible to use a black ("not white") and white color map sketch and set white areas to be walkable?

Or is there some other way to do it easily?

On this image, black areas represent walls at some height seen at some angle.

isometric

I also have more complex maze-like dungeon drawn:

bg2

I have searched quite some time but didn't find some satisfactory answer specific to my need.

\$\endgroup\$
1
\$\begingroup\$

I suggest that you place invisible "boxes" on the black area and then check for collision. I have drawn a few boxes where you could check for collision.

The red boxes are hitboxes

\$\endgroup\$
  • \$\begingroup\$ What if I have circular ones? Is it possible to automatize the process ? \$\endgroup\$ – eon Feb 18 '17 at 16:25
  • \$\begingroup\$ Btw, @Klemmensen , which boxes do you mean? How to get them in Unity ? \$\endgroup\$ – eon Feb 18 '17 at 16:27
  • \$\begingroup\$ You will have to do it "manually" where you add a box or circle and then you check for collision on it. You can however automate the collision detection by for example making a for loop that checks an array of objects if they collide with the target. \$\endgroup\$ – Klemmensen Feb 18 '17 at 16:33
  • \$\begingroup\$ In Unity, you can use Polygon Collider 2D (or Box Collider 2D if the wall shape isn't a freeform shape). Then assign the collider for a Rigidbody on the playable character. \$\endgroup\$ – Rama Alifiandy Feb 18 '17 at 16:43
  • \$\begingroup\$ Hm, can I draw walls in separate layer in Gimp and import that layer in Unity as image ? Then I would apply Polygon Collider 2D on walls image. I'm sure but this could work. Thank you. \$\endgroup\$ – eon Feb 18 '17 at 17:20
1
\$\begingroup\$

Yes, drawing a pixel collision map like that is possible. There are 3 issues tough:

  • If the walkable area gets too tight, rounding errors and frame based collision detection will allow players to get into corners they cannot ever get out of again. They get stuck. This is relatively easy to avoid if you keep shapes simple and walking spaces big.

  • Pathfinding is trickier the more obstacles there are. with pixel-based collision detection, every pixel is an obstacle.

  • You may want people to "slide" alongside walls. This isn't really possible with a pixel based collision map.

\$\endgroup\$

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.