I'm doing a test project and on a simple screen, without enemies, just a tilemap and a character moving with a 2D camera that follows me, the game drops every "x" seconds at 58 or 59 FPS and it's very noticeable because it jerks. ..
It's very annoying and I don't know how to fix it.
I am moving the character with _physics_process and move_and_slide().
In the debugger, Monitors and Profiler tab there is nothing that is excessively overloading the game...
Any ideas?
dandorf changed the title to Simple scene drops FPS to 58/59 and it shows a lot [3.5.1 stable / GLESS 3] .
Anyway, the same thing happens to me on my Android phone. I don't think it's a PC problem.
I put a test video of the game and you will see how it jerks... because the FPS drops from 60 to 58/59 from time to time (I have seen it in the debugger)
Pixophir That's what I thought, that it would be something insignificant, but it is too noticeable in the game... because it jerks every time it drops 1 or 2 FPS.
Then it is most probably something different from the mere frame rate, or even the flow of the game. Maybe a virus checker or some such ... but I can just guess without more information.
dandorf Without V-Sync it has very high FPS (700 approx) but it still jerks.
This is why for debugging purposes graphing the frametime is better. Also see what is going on in process and physics on the low rate/slow frames if you can. It might be something on the cpu side and not gpu that is bottlenecking/taking long on those frames.
The game so far is super simple, because I'm testing the main mechanics before starting game development.
I put a couple of images of the debugging of the game to see if it helps.
I ask out of ignorance...
Could the problem be due to the constant movement of the camera follow the player? because if I leave camera static those unwanted stutters don't happen
No, the camera would not cause that. But a moving camera can cause things to happen, such as objects appearing or disappearing, which could have an effect on the performance.
Honestly, the 59 FPS thing is not the problem. Even AAA games will hover around 58 - 62 FPS because it is not perfect, every frame is doing something different so it's not possible for it to be exactly the same.
The issue is probably with your logic being framerate dependent. If you use the delta parameter (the time of the last frame) and make sure all movement code is based on delta, then it doesn't matter the frame rate.
You could even have a game drop from 60 FPS to 45 FPS to 30 FPS and then back to 60 FPS and there will be no slow down. Granted it won't look as smooth, but there will be no difference in the speed of objects or hiccups.
So you might want to double check and make sure you are using delta and timing correctly, having the right things in physics process and/or process and updating correctly.
dandorf I'm using move_and_slide() in _physics_process and in that case I think it's not necessary to use _delta (I'm not actually using it).
For being independent from frame time, delta must be used to calculate the velocity of an object in _process or _physics_process. move_and_slide() then calculates the outcome of the object's position based on velocity.
But the differences here are so small that I doubt there is any visible effect, and I think what we see in the video is not in the engine or in the game, but some other process is causing it.
The code looks fine to me. Maybe speed should be a float, but I think it auto converts.
var speed = 450.0
What operating system are you using and what monitor resolution and refresh rate? It may be a system/OS issue and not Godot.
Also, that bounce code won't work. You should probably either check for collision or use an Area2D or ray cast to see if it touched the wall. You might want to remove that code.