Godot: move_and_slide in _physics_process + Camera2D == stutter

Created on 25 Dec 2018  路  11Comments  路  Source: godotengine/godot

I was working on a game and when I started doing some camera work I noticed that the camera did some weird shake/jitter when the character was moving it. After some googling (https://godotengine.org/qa/23021/move_and_slide-seems-to-have-a-bit-of-jitter) I found the answer to be that instead of placing the move_and_slide() into the _physics_process() it has to be in the _process() method.
I think this should have its own warning on the debugger to avoid the googling and the guessing.

discussion documentation enhancement physics

All 11 comments

Godot version?

And no, physics methods needs to be used on physics process only, the issue with the camera is something else, related to interpolation, probably.

Sorry, forgot to add the version, my bad. Latest alpha build (3.1)
If the issue is something else should I report it as a different thing? or edit this one.

May be better to create a new issue but there are a couple of different issues about jittering/stuttering, on 2D mostly, check if you find something first.

Also be detailed on your issue and add an example because some jittering is hardware dependant and hard to reproduce.

I'll do! 馃憤

This issue needs a discussion, I guess its purely a documentation problem, but Im not sure..

@Chaosus maybe needs documentation to reduce frustration on some devs.

But the main issue, about warning when using physics stuff when should not (like when using methods that only works on _draw) could be useful.

move_and_slide should be used in _physics_process, as written in its documentation. The fact that Camera2D stutters when doing so is a separate issue.

Could you provide an example project that reproduces the issue? The main problem is likely that Camera2D uses NOTIFICATION_INTERNAL_PROCESS and not NOTIFICATION_INTERNAL_PHYSICS_PROCESS. This could maybe be made configurable to avoid such inconsistencies.

move_and_slide should be in _process, or you are bounding player movement in your game to 60hz monitors. i think this has been said from 2015 or so as well, not sure why no one believes it :/

@girng one comment above yours @akien-mga said the exact opposite. (And docs say _physics_process, too: https://docs.godotengine.org/en/3.0/tutorials/physics/using_kinematic_body_2d.html?highlight=Move_and_slide#movement-and-collision)

And @girng: you can always alter the physics FPS...

With #24806, you can now set the process_mode property to PROCESS_MODE_PHYSICS to be in sync with your movement logic in _physics_process.

Was this page helpful?
0 / 5 - 0 ratings