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

Allow calling for Physics step from code #77073

Closed
wants to merge 2 commits into from
Closed

Conversation

Lcbx
Copy link
Contributor

@Lcbx Lcbx commented May 14, 2023

fixes #24769

exposes a function that calls a physics tick with the given delta type in parameter
also allows to set Engine.physics_ticks_per_second to 0

My particular use case is training AI in a sped-up, not-real-time environment.

related to #76462 but with a different approach

@Lcbx Lcbx requested review from a team as code owners May 14, 2023 17:36
@Calinou Calinou added this to the 4.x milestone May 14, 2023
@AThousandShips
Copy link
Member

To avoid having to make manual changes based on the CI errors consider using clang-format, as per the documentation

@Calinou
Copy link
Member

Calinou commented May 14, 2023

See also #49976, which is a previous proof of concept for implementing this feature. Related proposal: godotengine/godot-proposals#2821

My particular use case is training AI in a sped-up, not-real-time environment.

Out of curiosity, why not use the --fixed-fps command line argument for this purpose? If you need to toggle it at run-time, there's a PR for that 🙂

@akien-mga akien-mga requested a review from a team May 15, 2023 11:09
@Lcbx
Copy link
Contributor Author

Lcbx commented May 25, 2023

Out of curiosity, why not use the --fixed-fps command line argument for this purpose? If you need to toggle it at run-time, there's a PR for that 🙂

Interesting, I knew about headless but not that there was a way to do non-real-time simulation 🤔

In most deep learning environments, it is the training script that calls each simulation step (not the simulation environment) ; It would still make interfacing existing code easier if there was a native way to call a physics update in godot from code, but your suggestion is a valid solution. Thanks ! ☺

I guess it's up to whichever reviewer to choose to add my PR in godot.

There's probably a more elegant/flexible way to achieve the same thing, but it is serviceable enough for things like forcibly speeding jumping or rewinding time (the latter will need more than just this function though).

shana and others added 2 commits May 28, 2023 17:11
Non-realtime simulation can now be enabled at runtime and enabled
without having to use a command line argument.
@Lcbx Lcbx requested a review from a team as a code owner May 28, 2023 15:13
@Lcbx Lcbx closed this May 28, 2023
@Lcbx
Copy link
Contributor Author

Lcbx commented May 28, 2023

closing since I force-pushed to my master branch thoughtlessly
and C# build failed on the methods I added

@YuriSizov YuriSizov removed this from the 4.x milestone Dec 2, 2023
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 ability to iterate physics from script or lock physics to the rendered frame rate
5 participants