Camera limit

Hi,
why are we putting the camera limit logic into _process and not physics_process?

also I did it quite differently than your solution :

	if player and player.global_position.y < limit_bottom - viewport_size.y / 2:
		limit_bottom = player.global_position.y + viewport_size.y / 2

so that it works with any resolution, instead of a hard number.

4 Likes

If i understand correctly its calculating a hard limit so does not need the precision of calculating every physics frame so process is fine.
I do like your solution however, Thanks for sharing

Ok, I guess the answer will overwhelm my small knowledge, but that means that physics_process is called more than once a frame?
Anyway thanks for taking the time. :slight_smile:

Hi SilikOne,

I’ll clarify a little further for you :slight_smile:

Process is called once per frame but it is not tied to the physics simulation and is not frame rate independant which means it will run at different speeds on different machines.

Physics_process is called every physics frame, which is determined by the fixed physics step set in the project settings and makes this frame rate independant so wont be affected by the computers frame rate.

So to sum up, When should you use which?

Process should be for game logic and non physics based tasks
Physics_process should be for physics and anything that requires to be frame rate independant (Like actually moving the camera)

Hope this clears things up a little for you :slight_smile:

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms