Hello Guest

Author Topic: Struggling with character movement/physics.  (Read 4686 times)

EvilDeathCrab

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Struggling with character movement/physics.
« on: June 17, 2012, 09:34:42 am »
To get started, I'm fairly new to 2DTK and Unity, but I do have some scripting background.

I'm currently trying to make a test project where I have a sprite with a CharacterController object added to it (to take advantage of the normal physics engine without having to write my own). I'm currently running into a problem where whenever I use Move or SimpleMove (any sort of movement, really), my sprite will fly high into the sky (along the Y axis, the longer I hold down the movement key the larger the Y value becomes).

I'm not entirely sure what I'm missing here. Do sprites on a small scale (I'm using the Orthographic camera size of 1 and my sprites/test room is scaled accordingly) not play well with Unity physics? Am I missing some property somewhere that makes character controllers naturally attempt to move themselves to a higher Y value or is this a known limitation? Is there a workaround?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Struggling with character movement/physics.
« Reply #1 on: June 17, 2012, 11:55:57 am »
Hi,

It probably is due to the scales. If you're using an Ortho camera with size 1, then you should compensate your character controller movement amounts (and also gravity).

Alternatively you can scale up your ortho camera to a size where the default physics would work well, then change the value in your sprite collection and commit - the sprites should now appear 1:1 at this ortho size. You will need to reposition the sprites, but if you haven't spent a great deal of time doing that, this is likely the easiest option.

EvilDeathCrab

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Struggling with character movement/physics.
« Reply #2 on: June 18, 2012, 05:29:30 am »
Hi!

Thanks for the prompt response. That definitely did the trick. I just kicked everything up to ortho 10 and things worked just fine. I guess the physics engine doesn't like dealing with very small numbers.

The More You Know?