Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move_and_slide in _physics_process + Camera2D == stutter #24594

Closed
coppolaemilio opened this issue Dec 25, 2018 · 11 comments
Closed

move_and_slide in _physics_process + Camera2D == stutter #24594

coppolaemilio opened this issue Dec 25, 2018 · 11 comments

Comments

@coppolaemilio
Copy link
Member

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.

@eon-s
Copy link
Contributor

eon-s commented Dec 25, 2018

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.

@coppolaemilio
Copy link
Member Author

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.

@eon-s
Copy link
Contributor

eon-s commented Dec 26, 2018

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.

@coppolaemilio
Copy link
Member Author

I'll do! 👍

@Chaosus
Copy link
Member

Chaosus commented Dec 26, 2018

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

@eon-s
Copy link
Contributor

eon-s commented Dec 26, 2018

@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.

@akien-mga akien-mga changed the title Debugger should warn about move_and_slide in _physics_process. move_and_slide in _physics_process + Camera2D == stutter Dec 27, 2018
@akien-mga
Copy link
Member

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.

@girng
Copy link

girng commented Jan 6, 2019

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 :/

@timoschwarzer
Copy link
Contributor

timoschwarzer commented Jan 6, 2019

@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)

@timoschwarzer
Copy link
Contributor

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

@akien-mga akien-mga added this to the 3.1 milestone Jan 7, 2019
@akien-mga
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants