Hello Guest

Author Topic: tk2dCamera and Unity physics  (Read 5010 times)

Penwise

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
tk2dCamera and Unity physics
« on: December 07, 2012, 06:28:59 pm »
I'm currently researching 2d options for developing in Unity and have a question regarding the tk2dCamera cooperating with Unity physics that came up while I was reading the documentation.  In the documentation, it seems that the tk2dCamera is set up to use a scale of 1 world unit = 1 screen pixel.  This seems like it'd have trouble cooperating with Unity's built in physics engine, which expects game worlds to be at the scale of 1 unit = 1 meter.    I may simply be misunderstanding the documentation.

To clarify, if I'm reading the documentation correctly: if I'm working in a 2d world where, for example, a 32x32 tile represents a 1mx1m square, I'd have to multiply all of my forces (gravity, movement, etc) by 32 to achieve realistic results wouldn't I?  This seems like it would cause the usual issues of scale for collisions in high-velocity objects.  If this is the case, is there a simple way to configure or modify the tk2dCamera to operate on a different scale?  I'm not averse to modifying the sources or scripts directly, so if that's the answer I can work with it.

Otherwise, so far it seems like 2d toolkit's the answer I'm looking for.

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera and Unity physics
« Reply #1 on: December 08, 2012, 03:20:23 pm »
You can easily adapt the Unity physics units. I've not had any serious issues from scaling up force / gravity - obviously the scale is increased but the significant values are also much larger.

In a sprite collection, select all your sprites and scale by whatever amount you like. In tk2dCamera, you can then trick it to scale everything back up and get pixel perfection yet again using overrides and scales.