• Godot Help
  • Simple scene drops FPS to 58/59 and it shows a lot [3.5.1 stable / GLESS 3]

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.

Try changing line number 6 to:
func _process(_delta):

See if that changes it. I don't really see any reason that particular code has to be executing in physics step.

It does because they are calling move_and_slide and that calls into the physics engine.

I have found that using process is smoother, however can cause issues when the frame rate and physics step are out of sync.

So yes, that will likely fix the stutter, but may cause other issues down the road depending on how they use the physics engine.

    No, there is nothing wrong with the physics engine or Godot. It's probably just an error on their node setup.

    I see two problems that are likely causing this. One, the camera is a child of the player. This is not how it's supposed to be done.

    The camera should be on the same level as the player (siblings) and you can put a script on the camera that follows the player position.

    Second, the camera process mode is on physics when it should be on idle. Unless the camera itself is colliding with things, I think idle will be best as it syncs to the screen refresh or frame rate rather than the physics step.

    You can additionally click the smoothing enabled on the camera (after you move it outside the player and place the script) and this will further smooth out the movement for any small frame rate drops.

    There is very little reason to increase the physics step in a normal platforming game. If you think you need to do that, it will just be masking a bug, not solving the problem.

    I think I've read Camera2D as a child of KinematicBody2D is the way to make the camera follow the player. Where does it say it shouldn't be used that way?

    The physics process mode for the camera doesn't make any sense though. It should be set to idle.

    @dandorf, sharing your project would make it easier for other to test it and see what's going on.

      berarma I think I've read Camera2D as a child of KinematicBody2D is the way to make the camera follow the player. Where does it say it shouldn't be used that way?

      It doesn't say that anywhere. I just have a lot of experience and that is what I discovered. Maybe for simple tests you can make the camera a child, but in a real game you need to customize the properties of the camera (such as the bounding box, so it doesn't go past the edge of the screen) which you can't do properly if it's a child on the object it's supposed to be following.

      I'm not seeing any issue here, but I have a super computer so I wouldn't expect any frame drops. The code looks fine to me.

      What surprises me is that it also happens to me when I run it on my mobile (android).

      That's why I thought it wasn't my computer issue.
      I thought to make the game for mobile but this error is holding me back 🙁

      I downloaded Godot 4 to try just in case.

      Now I have created the same thing, as simple as possible and with Godot's automatically generated code for a Character2D....

      It keeps doing the same thing to me, it keeps giving those "jumps/stutters" that are very annoying.

      I have come to think that it could be something from my PC, but when I export to Android it has the same behavior, I don't understand anything...

      I have recorded a video with the result in Godot 4. Literally, the code is simply this:

      velocity.x = SPEED
      move_and_slide()

      It can not be much simple.

      (second 42) Notice how near the end of the video it stutters even when the FPS is at 60!!!!!!!!! 🙁 🙁

        dandorf it stutters even when the FPS is at 60

        then it's probably not fps related, though also worth noting that the rendering fps is separate from physics step/fps.

        The mystery deepens. OP have another computer perhaps to test?

          duane I just tried it and I am sometimes going down to 58 and making stutters.

          In your case, use _process, but the same thing happens to me. I tried to change it to _physics_process and it also goes wrong, even worse I think.

          Doesn't it give you problems executing your project?
          It is always stable and there are no stutters???

          Thanks to all for the help.

          It seems that we will never be able to solve it 🙁

            Erich_L I don't have another one at home.

            I'll try to tell a friend to try, to see what the results are.

            It is very strange, I have come to think that it may be my PC, but then it would not make sense that if I export it to Android it would have the same behavior and it would continue to stutter, right?

            🙁

              dandorf It is very strange, I have come to think that it may be my PC, but then it would not make sense that if I export it to Android it would have the same behavior and it would continue to stutter, right?

              For instance if the stutter is caused by another process running periodically and consuming many resources in an already resource-restrained environment, like a weak computer, or a mobile device. That's my opinion of what's happening.

              Can you list your full PC specs? I see your CPU listed, are you using the integrated GPU? What operating system? Everything updated with the OS and all drivers?

              PC Specifications:

              Graphic card:

              How can I tell if Godot is using the dedicated graphics card and not the integrated one? do you use it by default?