I’m working on a 2D platformer (big surprise haha), and I’m using my Snap settings to move 2D planes by set distances so that they can easily be placed together with pixel perfect accuracy. Also so that things in general can keep a consistent distance since it’s all pixel art in point filtering mode.
My issue though, is that the snap settings seem to sometimes add random fractions to my translations. My snap settings are set to 3.2 (32 pixels is how I’m working that out in relation to camera distance), and sometimes it translates it the right amount, so that I retain a value with only 1 or 2 decimal places, but sometimes it will add random decimal places and numbers, so I’ll end up with something like 3.1999999 or even more off than that, and from there it will compound the problem further since it is now working off a multi-decimal place number.
The problem happens instantly if you move the object from a positive position to a negative one, but also happens while only moving in a positive position as well after a while.
So, is anyone aware of this issue? I couldn’t find any posts about it. Perhaps it’s just the most recent version of Unity? This is my first time really using this engine.
(side question related to this. Would there be any negatives to working at a full 1unit=1pixel scale? As this would make my job even easier by only needing to work with integer values for most of the code. I’m just worried about things like player physics not being able to work as well? Or something else unknown to me)
I will have to have another read/think when I'm back on my pc. In the mean time hopefully someone will provide a better answer. "If the position continually worsens for objects" - is this happening or just something you predict? I wouldn't have expected that to happen. As for the pixel per unit, I'm not sure if I properly understand the benefit (but I guess I don't know what you're planning). In my opinion it seems easier to think of 1 unit = 1 meter, rather than thinking in pixels.
– hamstar@Invertex I missed the jitter issue. So the objects are jittering even though they are static? Or are you changing their position in code?
– hamstarJust in case, can you check that code which affects the player rigidbody is in FixedUpdate rather than Update. Also, if you are changing the camera position in code (e.g. to follow player) put that code in FixedUpdate ([read more][1]). I think I'll have to give up on this one and hope someone else has an answer. [1]: http://answers.unity3d.com/questions/37050/jittering-when-moving.html
– hamstarImo I wouldn't worry about what the inspector says unless the object LOOKS like it is in the wrong position. The position is always going to be stored as a float and floats are not 100% accurate.
– hamstar