From be15a570a791d716ee2059621f648fc0b811858e Mon Sep 17 00:00:00 2001 From: GamEsnitzhel Date: Sat, 16 Sep 2023 11:26:00 -0700 Subject: [PATCH 1/5] Added C# example --- .../best_practices/godot_notifications.rst | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tutorials/best_practices/godot_notifications.rst b/tutorials/best_practices/godot_notifications.rst index 5e1bdc16238..7a3494aa9f5 100644 --- a/tutorials/best_practices/godot_notifications.rst +++ b/tutorials/best_practices/godot_notifications.rst @@ -84,6 +84,26 @@ implementing a Timer-timeout loop is another option. print("This block runs every 0.5 seconds") ) + .. code-tab:: csharp + + using Godot; + + public partial class MyNode : Node + { + + // Allows for recurring operations that don't trigger script logic + // every frame (or even every fixed frame). + public void _Process(double delta) + { + var timer = new Timer(); + timer.Autostart = true; + timer.WaitTime = 0.5; + AddChild(timer); + timer.Timeout += () => GD.Print("This block runs every 0.5 seconds"); + } + + } + Use ``_physics_process()`` when one needs a framerate-independent delta time between frames. If code needs consistent updates over time, regardless of how fast or slow time advances, this is the right place. From d4c067513b3fc3a26c7bcc62562d498f219475db Mon Sep 17 00:00:00 2001 From: GamEsnitzhel Date: Sat, 16 Sep 2023 13:27:09 -0700 Subject: [PATCH 2/5] Fixed C# example in godot_notifications --- tutorials/best_practices/godot_notifications.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/best_practices/godot_notifications.rst b/tutorials/best_practices/godot_notifications.rst index 7a3494aa9f5..9e01ff7a979 100644 --- a/tutorials/best_practices/godot_notifications.rst +++ b/tutorials/best_practices/godot_notifications.rst @@ -84,7 +84,7 @@ implementing a Timer-timeout loop is another option. print("This block runs every 0.5 seconds") ) - .. code-tab:: csharp + .. code-tab:: csharp using Godot; From edec34f31f6fd90c59e370a0d996b6e73c332eaf Mon Sep 17 00:00:00 2001 From: GamEsnitzhel Date: Sat, 16 Sep 2023 23:24:18 -0700 Subject: [PATCH 3/5] Changed to _Ready() instead of _Process(double delta) --- tutorials/best_practices/godot_notifications.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tutorials/best_practices/godot_notifications.rst b/tutorials/best_practices/godot_notifications.rst index 9e01ff7a979..313c4c123a4 100644 --- a/tutorials/best_practices/godot_notifications.rst +++ b/tutorials/best_practices/godot_notifications.rst @@ -90,10 +90,9 @@ implementing a Timer-timeout loop is another option. public partial class MyNode : Node { - // Allows for recurring operations that don't trigger script logic // every frame (or even every fixed frame). - public void _Process(double delta) + public void _Ready(double delta) { var timer = new Timer(); timer.Autostart = true; @@ -101,7 +100,6 @@ implementing a Timer-timeout loop is another option. AddChild(timer); timer.Timeout += () => GD.Print("This block runs every 0.5 seconds"); } - } Use ``_physics_process()`` when one needs a framerate-independent delta time From ba278e94714f54d7d1dfe9f4f9f085ba58462c1e Mon Sep 17 00:00:00 2001 From: GamEsnitzhel Date: Sat, 16 Sep 2023 23:25:16 -0700 Subject: [PATCH 4/5] Actually remembered to remove (double delta) this time --- tutorials/best_practices/godot_notifications.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/best_practices/godot_notifications.rst b/tutorials/best_practices/godot_notifications.rst index 313c4c123a4..268b476cc39 100644 --- a/tutorials/best_practices/godot_notifications.rst +++ b/tutorials/best_practices/godot_notifications.rst @@ -92,7 +92,7 @@ implementing a Timer-timeout loop is another option. { // Allows for recurring operations that don't trigger script logic // every frame (or even every fixed frame). - public void _Ready(double delta) + public void _Ready() { var timer = new Timer(); timer.Autostart = true; From ca068de263522faf33b0534f0fca6f4ff132be71 Mon Sep 17 00:00:00 2001 From: GamEsnitzhel Date: Sun, 17 Sep 2023 10:56:13 -0700 Subject: [PATCH 5/5] Marked _Ready() as override --- tutorials/best_practices/godot_notifications.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/best_practices/godot_notifications.rst b/tutorials/best_practices/godot_notifications.rst index 268b476cc39..f710a59c14e 100644 --- a/tutorials/best_practices/godot_notifications.rst +++ b/tutorials/best_practices/godot_notifications.rst @@ -92,7 +92,7 @@ implementing a Timer-timeout loop is another option. { // Allows for recurring operations that don't trigger script logic // every frame (or even every fixed frame). - public void _Ready() + public override void _Ready() { var timer = new Timer(); timer.Autostart = true;