2
\$\begingroup\$

The question is just a logical extension of this question.

So, how should I render a cylindrical world space onto a flat, 2D view port in Unity?

Thank you.

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

The coordinates of any point on a cylinder can be expressed as (r, θ, z), where r is the constant radius of the cylinder, θ is the angle around the z-axis and z is the "height" of the point. You can convert that into 2D coordinates by throwing out r, treating θ as x and z as y.

Keep in mind that θ will be between 0 and 2π (or 0 and 360), so you'll need to scale that the appropriate width to look reasonable when projected onto the x coordinate. You'll also need to deal with the wraparound mathematically, probably by using the modulus operator. This blog post may be useful in coming up with ideas for how to deal with such edge cases.

You probably don't have cylindrical assets, but instead have 2D assets. As such, you should just be able to use them like you would any other 2D asset in Unity.

\$\endgroup\$
  • \$\begingroup\$ Will such an approach preserve the standard Unity 2D physic or will I have to write the 2D physics from scratch? Thank you. \$\endgroup\$ – iamyourfriend Feb 1 at 21:06
  • \$\begingroup\$ I would think it would work. I don't know much about Unity myself, though. I don't see why it wouldn't work. \$\endgroup\$ – user1118321 Feb 2 at 2:37
  • \$\begingroup\$ I just can not imagine how I would use a 2D Sprite Renderer on the cylinder. Thank you. \$\endgroup\$ – iamyourfriend Feb 3 at 21:11

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.