2
\$\begingroup\$

Here is my camera setting:

enter image description here

With this setting, when I run, game is not center of screen:

enter image description here Please tell me how to fix this.

thanks :)

\$\endgroup\$
1
  • \$\begingroup\$ Are your game objects in the center of the world coordinates? \$\endgroup\$
    – Philipp
    Feb 25, 2015 at 11:59

2 Answers 2

5
\$\begingroup\$

Your Camera is static, which is OK in your case. In order to make it display what you want, you just need to tweak it's position.

The screen size for this specific project is 7 x 7. For the camera to show it properly you need to set it's position to middle. And that's 3.5 x 3.5.

Update Main Camera's position to 3.5 X and 3.5 Y.

Position in the tutorial where the Camera position is set: http://youtu.be/7NYXBUWmFvU?t=3m

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ thanks :) It's work. Can you explain for me why 3.5 please ? \$\endgroup\$
    – hqt
    Feb 25, 2015 at 12:07
  • \$\begingroup\$ The screen size for this specific project is 7 by 7. For the camera to show it you need to set it's position to middle, that's 3.5 x 3.5. \$\endgroup\$ Feb 25, 2015 at 12:08
  • \$\begingroup\$ 7x7. why can you know that ? I don't see this number in camera setting. Does this default for all project ? Thanks :) \$\endgroup\$
    – hqt
    Feb 25, 2015 at 12:10
  • 1
    \$\begingroup\$ 7x7 is the game-zone size. You can get to that number by computing tile size * tile count. Anyway, in that tutorial it clearly asks you to set the Camera's position to 3.5x3.5 :) \$\endgroup\$ Feb 25, 2015 at 12:16
  • \$\begingroup\$ ah. i understand. thanks :) so. because you know tutorial that I'm viewing :D \$\endgroup\$
    – hqt
    Feb 25, 2015 at 12:51
1
\$\begingroup\$

In most games you will want to make the camera follow the player. A good way to do this is to make the camera a sub-object of the player. You can do this in the hierarchy window by dragging the Main Camera game object onto the player object, so it is listed below it with a slight indentation. That way the transformation coordinates of your camera object will always be relative to the player, not to the world origin.

Alternatively, when you would like the camera to be in fixed position instead, set the x- and y-position of your camera to half the x- and y- size of your scene.

\$\endgroup\$
2
  • \$\begingroup\$ Can you tell me how to get x-size and y-size of scene ? I don't see those parameters in camera setting. thanks :) \$\endgroup\$
    – hqt
    Feb 25, 2015 at 12:19
  • 1
    \$\begingroup\$ @hqt It's not a property of the camera. The size of your scene depends on how large you made it. How to find this number depends on how you made your game. \$\endgroup\$
    – Philipp
    Feb 25, 2015 at 15:36

You must log in to answer this question.

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