Hello,
I have recently begun implementing a system into a project where the physics fps will be adjusted to match the monitor refresh rate. To do this vsync is enabled and in the _process() function of an autoloaded script the fps is measured and then the physics framerate is set to it as such:
func _process(_delta: float) -> void:
var fps = Engine.get_frames_per_second()
if fps > 60:
Engine.iterations_per_second = fps
However this is causing an issue where objects that use the delta value of physics process are moving slower at high refresh rates such as 360Hz. Here is the movement code:
func _physics_process(delta: float) -> void:
direction.x = int(Input.is_action_pressed("MoveRight")) * Input.get_action_strength("MoveRight") - int(Input.is_action_pressed("MoveLeft")) * Input.get_action_strength("MoveLeft")
direction.y = int(Input.is_action_pressed("MoveDown")) * Input.get_action_strength("MoveDown") - int(Input.is_action_pressed("MoveUp")) * Input.get_action_strength("MoveUp")
if direction != Vector2.ZERO:
velocity = MAXSPEED * direction
else:
velocity = Vector2.ZERO
move_and_slide(velocity * delta)
Surely the decreased delta from the higher physics fps should be balanced out by having more physics frames? How do I fix this?