Collisions and Jerkiness Unity 2D

This must be a solved problem that I am failing to GoogleFu.

I’m learning Unity and building a simple model for a 2D puzzle game using the Unity’s physics engine. Right now, I’m having a problem with collisions being/looking precise.

Case 1

When my player object, a black square, collides into the walls of the arena (four rectangles forming a square arena), the player tends to penetrate slightly before bouncing out. It’s slight, and I’ve played with the “min penetration settings” but it’s noticeable and quite annoying.

Case 2

I’ve been playing with the 2D Slider Joint to create a platform that can slide along an axis. When my player collides into this platform along an axis that the slider joint shouldn’t move in, the joint/platform bounces.

For example, if my player is falling from top to bottom along the Y-axis, and the platform is constrained to move along the X-axis only, it’ll slightly shift along the Y-axis upon collision. What’s worse, it won’t bounce back and will continue to play out in its shifted position. When the player object falls off (say, gravity shifts to push it from bottom to top), the platform will jump back to its original position.

Again, pretty aggravating.


Are there any ways around this? Should I just be blowing up the size of my arena/player character so that these effects are less noticeable? Perhaps I’m playing with small units (My player character is 0.5 units large) so the effects are pronounced?

Or is this just something flawed with Physics systems or Unity’s physics system? In this case I’ll have to create my own physics system/movement system and that just seems really unfortunate for such simple cases.

Case1 is a limitation of the physics system. Physics calculations are intensive and so are limited by processing power of your system. The default physics calculation cycle in unity is 0.02 seconds, or 50 fps. Depending on the amount of physics interactions in your game and your target platform you can increase this cycle rate in Project Settings > Time > Fixed Timestep for better results. For example setting it to 0.01 will double the physics fps to 100 which will look better but also double the processing overhead. This should be fine for relatively simple physics based games.

Case2: Have you set “Freeze Position” on the Y axis in the Contstraints of your platform rigidbody? This should solve that problem. Probably should freeze Z rotation too.