Hello Guest

Author Topic: Physics and PTM ratio  (Read 6374 times)

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Physics and PTM ratio
« on: July 19, 2013, 03:31:44 am »
Hi,

I have a scene with Sprite + Animators and a TileMap layout and I'm having some issues with the physics and rendering.

I'm very new to Unity and their physics system as well, but even after taking your advice on the "Floaty Physics" thread, it still seems floaty. The player appears to move as if on skates, when they are in the air and move their speed increases significantly, and they bounce when landing. At first I thought it might have to do with rendering size and looked for a PtM (Pixels to Meters) ratio somewhere to set, which I found in the SpriteCollection settings. Just like in other 2D physics engines I've dealt with, I set it to 32 but this resulted in my sprites shrinking, becoming almost microscopic. I tried to set the Sprites' and the TileMap's PTM ratio to 32 so they would be of the same size when rendered, but the TileMap's size on screen wouldn't change so this doesn't seem to be the answer.

The question I'm trying to form is should the PTM for sprites and such be left at '1' and if so, what sort of forces should be applied to the sprites in order to achieve the typical, tight platformer feel?

Thank you.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Physics and PTM ratio
« Reply #1 on: July 19, 2013, 10:36:39 am »
2D Toolkit 2.1 has a pixels per meter setting (not sure if you're using that).

If you already have a tilemap set up and change the pixels per meter / any other size, you will need to open up your tilemap editor, and in tile properties, click "Reset". That will reset the tile sizes correctly.

If you want a tight platformer feel, your best bet is to use a custom raycast controller. Eg. this: http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1581.0.html <- its got a really tight feel to it.
Might be worth looking into something like this: http://forum.unity3d.com/threads/173640-Released-2D-Platform-Controller <- The author is working on a 2D Toolkit sample, which may make things a lot easier.

kwhittington

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Physics and PTM ratio
« Reply #2 on: July 19, 2013, 04:20:24 pm »
Thanks for the links!

Yes, I am using the PTM value in the 2D TK objects. I reset the TileMap and it did shrink to the same size as the other components, but I can't get anything in the field of view when I play the project. I can position the tk2dCamera so the preview shows all the other objects but when I hit play, they disappear. Would meddling with the PTM mess up the tk2dCamera since everything started with a PTM of 1?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Physics and PTM ratio
« Reply #3 on: July 19, 2013, 06:51:54 pm »
It shouldn't affect it at all really, as long as the PTM values matched in the sprite collection & camera. If you're still stuck with this, create a simple repro case and email it to support at unikronsoftware dot com.