Hello Guest

Author Topic: Question regarding camera, physics constant  (Read 3540 times)

luniac

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 23
    • View Profile
Question regarding camera, physics constant
« on: October 16, 2015, 10:37:25 am »
In your thread:
http://2dtoolkit.com/forum/index.php/topic,1746.0.html

you say the general formula that works pretty well is
1. Work out the screen height in meters from the top to the bottom of your game window screen. Eg. if you can stack up 10x 1 meter boxes to fill up your screen vertically, then thats 10 meters.

2. Work out the camera height - if you're using an orthographic camera, it will be the orthographic size * 2. If you use a tk2dCamera, it will be the height of your native resolution in pixels.

gravity.y should be around = -9.81 * camera height / screen height meters for things to fall naturally.


Can you elaborate on step 2 cause im not sure i understand it.

I have a 2d toolkit camera in my scene that uses default orthographic projection with "Pixels Per Meter" type set to 100 pixels per meter.
My native resolution height is 1280 pixels.

so for "camera height", what do i calculate? im not sure what orthographic size is since i use pixels per meter, i don't really use "orthographic size" type.
do i use the resolution height?

i checked with a 1 meter box for screen height and got 32 meters. so i do -9.81 * 1280 / 32 = -392.  thats a pretty high value.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Question regarding camera, physics constant
« Reply #1 on: October 18, 2015, 11:34:37 am »
With pixels per meter setting on tk2dCamera, you can work it out directly from what your pixels represent. At 1 pixel per meter, 1 pixel = 1 meter. At 10 pixels per meter, 1 pixel = 10cm.