I am developing a 2d isometric game and I was wondering if I can use a 3d plane for a 2d game.
Answer
Sure, you want an orthographic projection.
Aside from that, you can render using an isometric point of view. That will allow you to look at surface with square tiles and have them appear as isometric tiles. Also, should allow you to use 3D models in your isometric game without worrying about the projection.
The following is from the Wikipedia link above:
There are eight different orientations to obtain an isometric view, depending into which octant the viewer looks. The isometric transform from a point ax,y,z in 3D space to a point bx,y in 2D space looking into the first octant can be written mathematically with rotation matrices as:
where α = arcsin(tan 30°) ≈ 35.264° and β = 45°. As explained above, this is a rotation around the vertical (here y) axis by β, followed by a rotation around the horizontal (here x) axis by α.
(...)
The other 7 possibilities are obtained by either rotating to the opposite sides or not, and then inverting the view direction or not.
Emphasis mine.
Notice the article says there 8 possible such matrices. Some testing will be required to make sure you are use the right one for the coordinates of your map.
For unity, you want to set an orthographic matrix in Camera.projectionMatrix
and the isometric matrix shown above in Camera.worldToCameraMatrix
.
Note: I don't really have experience with Unity. So I can't tell if Camera.orthographic
is a better option than setting an orthograpic matrix to Camera.projectionMatrix
.
If you need to set the camera by hand, use the angles shown above (α = arcsin(tan 30°) ≈ 35.264° and β = 45°):
No comments:
Post a Comment