Log In  
Log In  

Cart [#bifajitedu-1#] | 2018-12-13 | License: CC4-BY-NC-SA | Embed

Trying to figure out why the player looks so jittery. I'm having the camera follow the player, and the ground below looks fine as the player moves, but the player itself is super jittery. In the embedded player here it looks fine, but while running in the designer, it's super jittery.

P#59971 2018-12-13 20:20

I found that if I move set_camera_world(x,y,z) to the end of _update() and remove it from _draw(), then the movement smooths out.

I'm guessing this issue is wrapped up in the fact that _draw() is being called every frame, rather than the way PICO-8 does it where it's being called 30 (or 60) times a second. That's just a total guess, though.

P#59974 2018-12-13 21:06 ( Edited 2018-12-13 21:07)

I spoke too soon. It seems super variable whether it jitters or not. On a reload of Voxatron, with no change in code, it started jittering. Reloaded Voxatron again and got no jitter. So, still not sure what's up. I still think it has to do with the timing of update and draw calls, but I'm not sure where to start debugging that.

P#59975 2018-12-13 21:19

I fixed this temporarily by re-writing the standard draw functions to make use of custom camera positioning variables, rather than relying on set_world_camera(). This is a total hack and is should only be used if you're running into the very specific problem I was having. Please don't consider this a good solution. It works, and that's all.

Put this in a script in your cart and call rewrite_draw_functions() from your _init() and then you can use set_camera(x,y,z) in your scripts instead of set_world_camera(x,y,z). (You can also use set_camera() of course to reset back to 0,0,0.)

--Standard draw functions re-written to fix 
--jitter from using set_world_camera(). To
--use, run rewrite_draw_functions() in _init()

function rewrite_draw_functions()

function set_camera(x,y,z)
 if (not x and not y and not z) then
  if (x) _cx=x
  if (y) _cy=y
  if (z) _cz=z

function __vset(x,y,z,c) _vset(x-_cx,y-_cy,z-_cz,c) end
function __vget(x,y,z) return _vget(x-_cx,y-_cy,z-_cz) end
function __box(x1,y1,z1,x2,y2,z2,c) _box(x1-_cx,y1-_cy,z1-_cz,x2-_cx,y2-_cy,z2-_cz,c) end
function __boxfill(x1,y1,z1,x2,y2,z2,c) _boxfill(x1-_cx,y1-_cy,z1-_cz,x2-_cx,y2-_cy,z2-_cz,c) end
function __line3d(x1,y1,z1,x2,y2,z2,c) _line3d(x1-_cx,y1-_cy,z1-_cz,x2-_cx,y2-_cy,z2-_cz,c) end
function __sphere(x,y,z,r,c) _sphere(x-_cx,y-_cy,z-_cz,r,c) end
P#59980 2018-12-13 22:41

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-01-18 19:02 | 0.021s | 4194k | Q:25