- Home /
Default Contact Offset Problems
Hi. So I am new to Unity and I am trying to make a 2d pixel platformer. However, I am having a problem. My character floats above the ground slightly, as you can see in this screenshot. I tried changing the default contact offset to 0.004 and that fixed my problem. But from researching a bit online, apparently this isn't a good solution as it could mess up collision? I don't really know why though. Is there a better way to solve this problem?
Answer by joemane22 · Mar 09, 2020 at 12:55 AM
My first reaction would be to edit the sprite so there is no extra pixels at the bottom.
You could also edit the sprite collider to better fit the sprite.
I've done both of these things. There are no extra pixels at the bottom of the sprite and the sprite collider fits the character perfectly. The ground collider is also pixel perfect.
Ok so as i understand it, the default offset for unitys physics engine is what the problem is. And you are shooting for pixel perfect rendering?
The only problem I could see arriving from changing that to be smaller is you may have some clipping through at higher speeds. However as long as you have interpolation set as an option for the collision detection I dont thing it would be much of an issue.
I would say keep that setting and cross that bridge if you run into an actual problem. I would definitely do some quick testing first though.
Run into some walls at high speed and such to see what it looks like.
Sorry for the simplistic answer at first, 95% of the time on here that is all it takes.
I would move to the forums for this kind of question as there are more technically skilled people that run around in there.