1
\$\begingroup\$

I have a 2d tile based game created using Unity's 2d tools and orthographic camera:

enter image description here

The tiles are created by programmatically generating a mesh, assigning a texture to each pair of triangles, and setting the normals to -Vector3.forward.

I'd now like to switch to a perspective camera, to add a 3d feel to the tiles, while still using sprites (and following the player):

enter image description here

How do I go about setting up this kind of camera, and will it still be possible to retain the player's x/y co-ordinates which are heavily used in my game logic.

Thanks in advance!

Update: I've realised that in terms of my original grid and sprites, I simply need to swap their vectors Y and Z co-ordinates so that the tiles and sprites are nicely positioned in the scene, however I'm still unsure about how to nicely position the camera and center it on the player.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

All you need to do is represent your sprites as 3D billboards, and backgrounds as 3D geometry (such as planes). The X/Y coordinates will be exactly the same as they were before. The camera will be offset from the player along the Z coordinate, and a little bit in the Y coordinate.

image

In unity, this can be accomplished by changing your camera type to a perspective camera, then having a script which follows the player and uses the lookAt function of the camera to orient it. The sprite renderer will work correctly, since in Unity, sprites are always just 3D billboards anyway. Your backgrounds will have to be converted into textured planes and other 3D geometry for them to be displayed appropriately though.

\$\endgroup\$
0
\$\begingroup\$

There are a couple things you will need to do here I believe:

1 Sorting the objects based on rendering order because they have a "Z component" 2 Translating the world coordinates into screen coordinates/scale by account for camera position 2 Touch up art assets that have a "depth" or "thickness" when portrayed in 3d space.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I doubt it's even that complicated. You have a 3D scene. Each sprite needs a plane to exist on, and that plane should always exist perpendicular to the camera. Though I don't know Unity, I know this is easy to do yourself, but I assume Unity has you covered. Sprites in a 3D setting are more common than you can imagine. Everything can still happen in 2D, with no thought of Z. Z only exists for the camera. \$\endgroup\$
    – Magus
    Jul 2, 2014 at 23:01

You must log in to answer this question.

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