Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Frame option to Timer node #10879

Open
CoreTaxxe opened this issue Oct 2, 2024 · 3 comments · May be fixed by godotengine/godot#97725
Open

Add Frame option to Timer node #10879

CoreTaxxe opened this issue Oct 2, 2024 · 3 comments · May be fixed by godotengine/godot#97725

Comments

@CoreTaxxe
Copy link

Describe the project you are working on

Creating a doomlike, retro-styled or fighting game where frame accuracy is crucial. (For example for combos, invincibilities) where time-based timers are not sufficient or can't guarantee frame-accurate timings. A lot of new comers starting to program re-create games/programs they know. Providing them with the tools they expect seems the best way to get them started.

I am aware that you typically don't want to use frames anymore. But in some rare occurrences you might and given this feature is opt-in/optional users who want to use it can. (Especially since they could also just go through the tiny but tedious process of writing it themselves anyways)

First draft implementation:
#97725

Describe the problem or limitation you are having in your project

QOL Feature to ease the use of frame timers. Otherwise, users have to create custom nodes or re-implement frame counters every single time over again.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Frame timers, different from time based timers, are directly bound to either physics or process frame rate thus guaranteeing deterministic and accurate results even through frame lags.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add an opion to the timer node that allows to chose between Frame and Time mode. In frame mode frames are counted instead of seconds.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes.

Is there a reason why this should be core and not an add-on in the asset library?

Its a very simple to implement, has pretty much 0 need for maintenance and is too simple too be worth an addon.

@AThousandShips
Copy link
Member

Beyond the issues with relying on fixed frame counts, this is so enormously trivial to accomplish, you just add a counter variable to your class and count it in _process or _physics_process, this avoids adding a whole separate node and using signals, much simpler and easier

@CoreTaxxe
Copy link
Author

I agree for very simple counters that is indeed overkill. However as soon as you have more than 1 counter it gets really messy. Especially if you want pause, restart or change behavior you have to spend significant amount of code.

@AThousandShips
Copy link
Member

I really do not expect any user to be needing that, this is an extreme edge case to begin with, and not recommended practice

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

Successfully merging a pull request may close this issue.

2 participants