(-o^_^)-o HugMonster Wrestles with Unity3D’s Physics

I’ve written physics engines before, though they were mostly simple affairs, and because I wrote them I have a pretty decent understanding of why they do what they do and how their limitations work.  Unity’s physics engine, being one that I did not write myself, is a little more opaque at the moment.  It buys you a lot right out of the box, such as gravity and velocity, and the ability to apply forces and torques.  Where the engine’s benefits are a little less clear is this particular 2D platformer.

When using Unity physics, the documentation recommends that you use only velocity to move objects with colliders and rigidbodies, rather than translating the transform.position directly.  Okay, fair enough.  I dig that.  I do that sort of thing too, updating world space and translating to pixels.  What’s a little less clear though is why collisions against walls are as goofy as they seem to be.  I’d like to simply have characters, when they jump while pressing into a solid wall, to actually reach the full height of their normal standing jump before falling, but colliding with velocity into the side of a box collider adversely effects the y velocity so the jump is simply not as high as it “should” be.

On the one hand I would really rather not re-implement physics if I can at least fake Unity’s physics into working well.  On the other hand, I. Just. Want. It. To. Work. Like. I. Expect.

Comments

Shigor
17. Dec 2011 · 18:38 UTC
What are you using for character? If you’re using character controller, take a look at the “skin” setting :)
dr_soda
17. Dec 2011 · 19:00 UTC
Hey there!
Shigor
17. Dec 2011 · 21:19 UTC
For a simple platformer Character controller is probably better choice, although it does have it’s problems. If you’re using normal rigid bodies, check what colliders you’re using. Sometimes changing collision type to continuous (you can afford it for simple objects) can help a lot (collision testing is a bit… actually not very accurate :).