From eee59dfa6abfe524254cae933572d84a61677ce7 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Fri, 6 Jan 2023 16:49:36 +0100 Subject: [PATCH] custom actual working jitterfix --- project.godot | 1 - src/window.cs | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/project.godot b/project.godot index e0a66c1..a657173 100644 --- a/project.godot +++ b/project.godot @@ -13,7 +13,6 @@ config_version=5 config/name="Godot Mono thirdperson controller" run/main_scene="res://scenes/main.tscn" config/features=PackedStringArray("4.0", "Forward Plus") -run/max_fps=60 boot_splash/show_image=false config/icon="res://icon.png" diff --git a/src/window.cs b/src/window.cs index 1355609..ec58df8 100644 --- a/src/window.cs +++ b/src/window.cs @@ -3,12 +3,19 @@ using System; public partial class window : Node { - public override void _Ready() - { - ProjectSettings.SetSetting("physics/common/physics_ticks_per_second", Performance.GetMonitor(Performance.Monitor.TimeFps)); - } - - public override void _Process(double delta) + public override async void _Ready() + { + /* VSync should be used because needing to change the PhysicsTicksPerSecond in _Process takes CPU ussage + * You could also just set max FPS and delte this fix + */ + await ToSignal(GetTree().CreateTimer(2f), "timeout");//waits until the game has loaded some time + if (Engine.PhysicsTicksPerSecond != (int)Engine.GetFramesPerSecond()) + { + Engine.PhysicsTicksPerSecond = (int)Engine.GetFramesPerSecond(); //PhysicsTicksPerSecond have to be the same value like current FPS or the movement will lagg + GD.Print("Set PhysicsTicksPerSecond to: " + Engine.PhysicsTicksPerSecond); + } + } + public override void _Process(double delta) { if (Input.IsActionJustPressed("fullscreen")) {