I am making an endless jumper game, I move the object by updating its y-axis. As the game progresses y-axis is reaching high numbers causing the game to become “zig-zaggy”. Is it okay if a game object’s vector reaches high numbers?
Well, “ok” is a subjective term here. You have to decide what is ok.
It’s quite easy to get floating point precision issues, especially if you try to increment floating point numbers “forever”. Even though Lua supports double precision floats, we store them as single precision floats internally. And depending on your precision in your shaders, you can get artifacts there as well.
Here’s a post about floating point precision with more info about the actual “issue”.
For you use case, I’d keep the player close to origin (e.g at a fixed position), and instead spawn geometry close by, and let it animate towards the player. That way all floating point values are quite low, and will keep their precision at an acceptable level.
That’s the trick: don’t move your player’s Y value, move the Y value of everything else!
I had a similar issue.
I had a ball falling continuosly and different blocks would be spawning on the way. After some time ball started to animate laggy (not moving smoothly but jumping between positions) and I thought I had issues with update(spending more than frame time) but this issue seems to be the reason.
One question that comes to my mind is can I use builting physics in that case? Negative gravity can be solution but for my case I don’t want blocks to move independent, they should me moving together so user gets the sense of ball falling.
Physics is yet another computation heavy system which is very dependant on numerical stability. So, here too you’ll want to keep physics objects closer to origin.