The value of "GetCameraScale()" seems to update too slowly compared the actual timing of the player zooming in/out.
This becomes a serious issue when the position of drawn objects is calculated using the value returned by this function. For example the new 3D Starfield Engine
For about half a second, the stars move to the position they would be in if they were being drawn on a flat plane
Then, they "jump" to their correct positions like it was 3D.
I have studied this behaviour extensively and done my best to isolate what causes it. The thing I keep coming back to is the GetCameraScale()
command. It's not a FPS issue - this bug occurs even with 1 star and 100fps. The effect is especially pronounced when you are zoomed all the way in.
Here is why I think it's GetCameraScale()
that causes the issue.
In the Parallax engine, in which the bug was NOT present, the position of stars was calculated like this:
starX[i] = (GetCameraX() / zdepth[layer]) + SetStarX[i]
starY[i] = (GetCameraY() / zdepth[layer]) + SetStarY[i]
is the ID of the star, starX
is the drawn position
of that star, zdepth
is the "parallax factor" of the layer that star happens to be on, and SetStarX
is the initial, assigned position of the star.
Notice that GetCameraScale()
is never invoked here. So the delay is not present.
In the new 3D Starfield Engine, the values are calculated, in part, based on the current camera scale.
Specifically, the line below takes the camera's scale and modifies it to a value that represents the Z-coordinate of the camera.
local CameraZ = (-1 / GetCameraScale()) * zscalefactor
The variable CameraZ
is later used to calculate the X and Y positions of stars.
The inclusion of Camera Scale induces this drawing update latency.
I have delayed reporting this for several days until I was satisfied none of my own code could be causing this.
Alex, PM me or reply here if you would like a copy of a prototype of the engine, so you can see the erroneous behaviour (and the stars!) for yourself.