Hello Guest

Author Topic: 2d toolkit Camera Clamp Setup  (Read 3625 times)

JackMariani

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
2d toolkit Camera Clamp Setup
« on: August 02, 2015, 11:52:22 am »
Hi, I'd like my 2dtoolkit camera to always stay within the borders of a background (made of multiple game objects), also if I zoom in and out, keeping the pixel perfect view.

My camera setup is the following:
https://www.dropbox.com/s/4wlh9pcj2pd1qym/camera.png?dl=0

Let me know if the setup can be adjusted. The basic element of my game is a Unity Sprite of 64 x 64 pixels.

That said. I know the position of the bottom left element (that is a gameobject with 64x64 sprite) and the top right (same type of game Object is a 64x64 sprite).
Example:
https://www.dropbox.com/s/j3iwg5fotwc4kjz/Tile.png?dl=0

The position of these elements may change depending on the scene level. But they will stay fixed for all the scene, so I need to adjust this just after each level loading.

How can I clamp the camera between these 2 gameobjects (to avoid showing outside elements in the view)?
How is the best way to zoom in and out without losing the pixel perfect? (ex. changing the zoom factor or the ortographic size).

Thank you very much in advance.
« Last Edit: August 03, 2015, 11:49:15 am by JackMariani »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2d toolkit Camera Clamp Setup
« Reply #1 on: August 05, 2015, 10:34:44 am »
A couple threads to help with clamping to playable area -
http://2dtoolkit.com/forum/index.php/topic,297.msg1262.html#msg1262
http://2dtoolkit.com/forum/index.php/topic,4770.msg22104.html#msg22104

Re: Zooming the camera - as soon as its scaled in any way it will no longer be pixel perfect, you can't get pixel perfect results if you scale... Eg. 1 pixel gets scaled to 2, or 2 to 1 - its lossy.