Sunday, March 03, 2013

Unity engine: creating a 2d game project

Camera > Projection > Orthographic

Change resolution: Edit > Project Settings > Player > Resolution

Orthographic size is half of the vertical size of the viewing volume. (defined in Unity Reference: http://docs.unity3d.com/Documentation/ScriptReference/Camera-orthographicSize.html)
so if the resolution is set as 640x480. then for a 1:1 mapping the size is 480 (height in pixels) / 2 = 240.

Camera Preview may show more in the window compared to set resolution. but when build and run. actual app displays fine.

rotated camera x-axis: 180 deg
change ambient lighting to #FFFFFF or RGB (255, 255, 255). Edit > Render Setting > #FFFFFF

using following OBJ plane format to create a simple 2D plane in the XY plane:
# vertices x, y, z
v 0.000000 1.000000 0.000000
v -1.000000 1.000000 0.000000
v 0.000000 0.000000 -0.000000
v -1.000000 0.000000 -0.000000
# texture coordinates in u,v. (0,0) is bottom left corner
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 1.000000 1.000000
# normal: x, y, z
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
# faces  1st point: vertex/vtexture/vnormal, 2nd point, 3rd point, etc.
f 1/1/1 2/2/2 4/4/3 3/3/4

texture working properly.




No comments: