+1 vote

I am fairly new to Godot, but I understand that using process(delta) will run the code every frame, while _physicsprocess(delta) will run the code inside at a fixed rate. Looking at that, it seems fairly simple that using physics_process would be a good choice for dealing with physics and such. However, if I leave the Physics Fps at default, all the code running inside of it looks like it's running at 60fps, which does make sense I guess. I've changed it to 144 and it looks very smooth, but could that mess things up for those with less powerful computers? I'd like my game to have consistent physics, and I know that it still technically runs at a higher framerate than the physics process, but I also would really like for the game to be able to visually run at whatever refresh rate the player has, whether it be 60, 90, 144, 240, etc. I'm very sorry if this is a dumb or convoluted question, but is there any way to have a game look as smooth as the refresh rate of the monitor (so long as the PC has the power to drive it that fast) while having consistent physics between different framerates and refresh rates?
If not, would putting the physics Fps at a very high number (e.g ~240) cause issues if a PC were to not be able to get that many FPS?

Thank you so much in advance!

Godot version 3.2.2
in Engine by (13 points)

1 Answer

–1 vote
extends KinematicBody2D

var velocity:Vector2
var speed:float = 60

func _physics_proccess(delta):
    velocity.x = speed*delta

By multiplying speed by delta you are multiplying it by the amount of time between frames, doing this will make the object move at the same speed no matter the frame rate while you will still be able to change its speed through code.

by (659 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.