- Home /
Any way to achieve Pixel Movement, and not floating point movement?
Hello. I'm making a NES Inspired game, and i can't figure out quite how to move a sprite pixel by pixel instead of using vector3 movement. I've heard that unity can't do pixel by pixel stuff. cause it's all in floating point positions, (Vector3.)
Any way i can do this????
Answer by LaireonGames · Feb 23, 2015 at 10:41 PM
I've heard that unity can't do pixel by pixel stuff. cause it's all in floating point positions
I have no idea who told you that or what they are talking about since that makes no sense! If you want to convert to pixels you will have to do some calculations to convert position, images etc to screen space. Otherwise/in general you can simply use the standard vector3 stuff but convert/round each value to an int each frame.
To be honest I don't recommend doing this since it will look jerky but it means things will only move on a point for point basis which I think is what you are aiming for
Thank you sir. I was watching a tutorial, and some guy said that movement was floating point Vector3 stuff. Sorry if it did not make any sense :) Thanks for answering! It helped!
If your pixels to units ratio is 100 to 1 then moving your transform by 0.01 each time should move it pixel by pixel. You have to make sure that your transform starts out at a point that is a multiple of 0.01 already.
I use this if I need to snap a transform to a pixel:
transform.x = $$anonymous$$athf.Round(transform.x * 100f) / 100f;
Your answer
![](https://koobas.hobune.stream/wayback/20220613184143im_/https://answers.unity.com/themes/thub/images/avi.jpg)