X Tutup
Skip to content

Add game speed controls to the embedded game window#107273

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
DexterFstone:add-game-speed-controls
Oct 6, 2025
Merged

Add game speed controls to the embedded game window#107273
Repiteo merged 1 commit intogodotengine:masterfrom
DexterFstone:add-game-speed-controls

Conversation

@DexterFstone
Copy link
Contributor

@DexterFstone DexterFstone requested review from a team as code owners June 8, 2025 06:30
@AdriaandeJongh
Copy link
Contributor

Love this functionality! But the UX of this needs work – because if the user wants to slow down a lot to see a specific thing in slow motion and then resume normally, it needs a LOT of clicks with this interface.

Perhaps a dropdown (probably), a small slider, or a small field where one can enter a percentage.

@DexterFstone
Copy link
Contributor Author

Perhaps a dropdown (probably)

image

@AdriaandeJongh
Copy link
Contributor

Cool! Without the << and >> buttons, I think the UX is a lot better.

@DexterFstone
Copy link
Contributor Author

DexterFstone commented Jun 8, 2025

Cool! Without the << and >> buttons, I think the UX is a lot better.

Do you think the speed reset button is needed?

2025-06-08.05-49-17.mp4

@AdriaandeJongh
Copy link
Contributor

Arguably it would be great to be able to reset to 1.0x using a little reset button (like the one used to reset variables to their default in the inspector!), but we wouldn’t want the bar to grow or shrink in width. maybe there’s a clean solution to this?

@DexterFstone
Copy link
Contributor Author

maybe there’s a clean solution to this?

I have two solutions, the first is to reset the value by right-clicking on the menu button, the second is to add a button to reset it, when the value is one, the button is not hidden and only disabled.

@AdriaandeJongh
Copy link
Contributor

as right clicking is hidden, the button is probably a better idea?

@YeldhamDev
Copy link
Member

The current implementation changes several values directly. Instead, they should override those temporarily (and add up to those that have been changed in the game itself) and go back to their original values once done.

@YeldhamDev
Copy link
Member

Let me give you a example:

  • The user's game overrides the game speed (set_time_scale()) manually for some gameplay reason. Lets say a value of 1.2.
  • With the current implementation of your PR, the current value set by the user is erased in favor of the one chosen in the UI.
  • The correct implementation would be to temporally override it, and to also add up to it. So if the user picks 0.5 in the UI, it will still remember that the original ingame value was 1.2, and change the speed internally to 0.6. And setting it in the UI back to 1, will set it back to 1.2.

This is how it's done for the mouse mode behavior as well.

@Calinou
Copy link
Member

Calinou commented Jun 9, 2025

Cool! Without the << and >> buttons, I think the UX is a lot better.

The reason I wanted those buttons is to have keyboard shortcuts for them, but we can replace it with a toggle that enables the speed override instead. This means you could toggle between slow motion and full speed, or full speed and fast-forward. It would use remember the last selected speed to toggle back to every time you press the shortcut (on startup, it'd default to 2×).

Emulators generally have a key you can press (or hold, like in Dolphin) to enable turbo mode. They sometimes have a separate slow motion key though (as well as frame advance).

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 0732f18 to dd5849c Compare June 10, 2025 04:39
@DexterFstone DexterFstone requested a review from a team as a code owner June 10, 2025 04:39
@DexterFstone
Copy link
Contributor Author

Let me give you a example:

  • The user's game overrides the game speed (set_time_scale()) manually for some gameplay reason. Lets say a value of 1.2.
  • With the current implementation of your PR, the current value set by the user is erased in favor of the one chosen in the UI.
  • The correct implementation would be to temporally override it, and to also add up to it. So if the user picks 0.5 in the UI, it will still remember that the original ingame value was 1.2, and change the speed internally to 0.6. And setting it in the UI back to 1, will set it back to 1.2.

This is how it's done for the mouse mode behavior as well.

I updated the code so that time_scale can be changed both by code and the UI at the same time.
Should I do this for physics_ticks_per_second and max_physics_steps_per_frame as well?

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from dd5849c to 6083546 Compare June 10, 2025 06:58
@YeldhamDev
Copy link
Member

Should I do this for physics_ticks_per_second and max_physics_steps_per_frame as well?

They can also be changed by the user, so yes.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 6083546 to b46b8c2 Compare June 11, 2025 08:31
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from b46b8c2 to addc7bc Compare June 11, 2025 09:34
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from addc7bc to b233c0c Compare June 11, 2025 09:57
@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from b233c0c to 9bb5cb0 Compare June 11, 2025 10:32
@DexterFstone
Copy link
Contributor Author

2025-06-11.05-48-48.mp4

There's a problem, don't I?

@YeldhamDev
Copy link
Member

Could you rebase it? It's still on Godot 4.5.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 1e5a271 to 79680c4 Compare October 2, 2025 12:03
@DexterFstone
Copy link
Contributor Author

Could you rebase it? It's still on Godot 4.5.

@YeldhamDev Done.

@YeldhamDev
Copy link
Member

Opening the editor spits this warning:

scene/gui/control.cpp:3090 - Attempting to access theme items too early in GameView; prefer NOTIFICATION_POSTINITIALIZE and NOTIFICATION_THEME_CHANGED

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 79680c4 to 189404a Compare October 2, 2025 14:19
@DexterFstone
Copy link
Contributor Author

Opening the editor spits this warning:

scene/gui/control.cpp:3090 - Attempting to access theme items too early in GameView; prefer NOTIFICATION_POSTINITIALIZE and NOTIFICATION_THEME_CHANGED

@YeldhamDev fixed. (I think)

@YeldhamDev
Copy link
Member

I can still reproduce it.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 189404a to 808b82b Compare October 3, 2025 11:14
@DexterFstone
Copy link
Contributor Author

I can still reproduce it.

@YeldhamDev now fixed

Copy link
Member

@YeldhamDev YeldhamDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with my game that heavily relies on changing the game's speed, and everything seems to be working fine.

@YeldhamDev YeldhamDev modified the milestones: 4.x, 4.6 Oct 3, 2025
Copy link
Member

@syntaxerror247 syntaxerror247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation needs some changes. The logic for speed control is currently implemented in the GameView and since GameView not used in the Android Editor (we use native implementation there), so it won't be possible to support this feature on Android Editor.

This is also inconsistent with other debugger options because others are handled in GameViewDebugger.

We should move the core logic into the GameViewDebugger (keeping the UI related logic in GameView) and expose methods like set_speed_multiplier(value) and reset_speed(). This would allow to call these methods from the Android side.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 808b82b to 92bdf15 Compare October 4, 2025 12:13
@DexterFstone
Copy link
Contributor Author

@syntaxerror247 Done

Copy link
Member

@syntaxerror247 syntaxerror247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just make sure to address the nitpick I mentioned above.

@DexterFstone DexterFstone force-pushed the add-game-speed-controls branch from 92bdf15 to 60868ae Compare October 5, 2025 04:40
@syntaxerror247 syntaxerror247 force-pushed the add-game-speed-controls branch from 60868ae to 7ddce8a Compare October 5, 2025 05:46
@Repiteo Repiteo merged commit 3b04c84 into godotengine:master Oct 6, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 6, 2025

Thanks! Congratulations on your first merged contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add slow motion and fast-forward controls to the embedded game window
X Tutup