I'm trying to move a kinematicbody2d across the screen at a smooth rate using move_and_slide().

I note the docs say this should be called from within Node._physics_process() as it uses the delta parameter (which should be constant).

However, I seem to have some jitter, and it's not 100% smooth. From previous experience I know I can use the process() function with the delta to get frame-rate independent movement - and this is how I've learned to do it in the past with other languages. Does this mean that 100% smooth movement cannot be made with kinematicbody2d's using the move_and_slide() function in the physics_process() function? If I manually move a node by multiplying the delta parameter in _process() I can get it very smooth.

Thanks

I think the move_and_slide function applies delta to the movement automatically, so you might not need to add it (and that could be causing the slight jitter)

I'll add another note that if your physics body's transform is being change outside of the physics engine you might also get jitter

I got the smoothest motion by updating positions (using move and slide) from inside process. Especially if you have a high refresh monitor, using physics_process is not smooth (even though I know this is what the docs recommend).

Hi - thanks for the replies. Just to confirm, I'm not manually adding the delta before calling move_and_slide(). The question is more "can 100% smooth scrolling be achieved with move_and_slide()?" considering that it is supposed to be run in physics_process() and not process(), therefore no smoothing or interpolation based on system load or framerate is happening.

Interesting @cybereality that you tried it in process(). Do you know if move_and_slide() uses the constantly changing delta from process() internally, or would it always use the fixed delta from _physics_process() regardless from where it is called? (in which case maybe the smoother scrolling you experienced may be because it is just calling it more often?)

Thanks again.

I haven't looked at the source code, but my experience has been that it uses the delta of the function it is within, which means in _process it would be called for every frame.

2 years later