Hello everyone, I’m trying to implement a 3D pseudo race on Defold. In the process, I have unknown performance problems. Now the Defold project should look like an example from the sixth step of this instruction:
https://www.lexaloffle.com/bbs/?pid=69343
In the example for Pico 8, there is a code for updating the position of the camera, it does not allow the camera to fly outside the road:
function _update()
camz += 0.1
if camz > 1 then
camz -= 1
camcnr, camseg = advance(camcnr, camseg)
end
end
In my code, I released this algorithm in a similar way by renaming the advance function and adding a variable dt:
function M.reset_camera_pos()
M.pos.z = M.pos.z - 1 -- 0.001
M.next_step()
end
The problem is that at low speeds self .CAMERA_SPEED <16, lags occur when the function m.reset_camera_pos () is called. As far as I understand, the lags occur precisely because of this arithmetic operation, because if I change m.pos.z = m.pos.z - 1 to m.pos.z = 0.001 - the lags become more often until the project is hanging.
I tried to find out the exact reason, but I could not figure it out on my own. The situation itself is strange, examples on Pico 8 and JS use identical implementations of this operation, but in them I have not seen such problems.
I will be glad of any help, thanks in advance!