Engine
Provides access to engine properties.
Provides access to engine properties.
The Engine singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others. It also stores information about the current build of Reckfell, such as the current version.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties8
MaxFpsProperty
public static int MaxFps { get; set; }Live rendering frame-rate cap. Zero removes this cap, but does not disable V-Sync or guarantee achieved FPS. Changing this property does not rewrite application/run/max_fps; writing that setting with SetSetting does not change the live property either.
MaxPhysicsStepsPerFrameProperty
public static int MaxPhysicsStepsPerFrame { get; set; }The maximum number of physics steps that can be simulated each rendered frame.
Note: The default value is tuned to prevent expensive physics simulations from triggering even more expensive simulations indefinitely. However, the game will appear to slow down if the rendering FPS is less than 1 / max_physics_steps_per_frame of Engine.PhysicsTicksPerSecond. This occurs even if delta is consistently used in physics calculations. To avoid this, increase Engine.MaxPhysicsStepsPerFrame if you have increased Engine.PhysicsTicksPerSecond significantly above its default value.
PhysicsJitterFixProperty
public static double PhysicsJitterFix { get; set; }How much physics ticks are synchronized with real time. If 0 or less, the ticks are fully synchronized. Higher values cause the in-game clock to deviate more from the real clock, but they smooth out framerate jitters.
Note: The default value of 0.5 should be good enough for most cases; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
Note: When using a custom physics interpolation solution, or within a network game, it's recommended to disable the physics jitter fix by setting this property to 0.
PhysicsTicksPerSecondProperty
public static int PhysicsTicksPerSecond { get; set; }Physics tick frequency. Ticks and rendered frames need not be one-to-one; increasing frequency needs CPU measurement and does not repair filters, geometry or arithmetic precision.
PrintErrorMessagesProperty
public static bool PrintErrorMessages { get; set; }If false, stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the ProjectSettings.application/run/disable_stderr project setting.
Note: This property does not impact the editor's Errors tab when running a project from the editor.
Warning: If set to false anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. In a @tool script, this will also impact the editor itself. Do not report bugs before ensuring error messages are enabled (as they are by default).
PrintToStdOutProperty
public static bool PrintToStdOut { get; set; }If false, stops printing messages (for example using ReckfellApi.Print) to the console, log files, and editor Output log. This property is equivalent to the ProjectSettings.application/run/disable_stdout project setting.
Note: This does not stop printing errors or warnings produced by scripts to the console or log files, for more details see Engine.PrintErrorMessages.
SingletonProperty
public static EngineInstance Singleton { get; }TimeScaleProperty
public static double TimeScale { get; set; }Game-time scale. It neither measures actual FPS nor replaces pause/ProcessMode. Check time-dependent forces, timers and input for the intended scenario.
Methods41
CaptureScriptBacktracesReckfell.Collections.Array<ScriptBacktrace>
public static Reckfell.Collections.Array<ScriptBacktrace> CaptureScriptBacktraces(bool includeVariables = false);Captures and returns backtraces from all registered script languages.
By default, the returned ScriptBacktrace will only contain stack frames in editor builds and debug builds. To enable them for release builds as well, you need to enable ProjectSettings.debug/settings/csharp/always_track_call_stacks.
If include_variables is true, the backtrace will also include the names and values of any global variables (e.g. autoload singletons) at the point of the capture, as well as local variables and class member variables at each stack frame. This will however will only be respected when running the game with a debugger attached, like when running the game from the editor. To enable it for export builds as well, you need to enable ProjectSettings.debug/settings/csharp/always_track_local_variables.
Warning: When include_variables is true, any captured variables can potentially (e.g. with C# backtraces) be their actual values, including any object references. This means that storing such a ScriptBacktrace will prevent those objects from being deallocated, so it's generally recommended not to do so.
| Name | Type | Default |
|---|---|---|
includeVariables | bool | false |
Reckfell.Collections.Array<ScriptBacktrace>GetArchitectureNamestring
public static string GetArchitectureName();Returns the name of the CPU architecture the Reckfell binary was built for. Possible return values include "x86_64", "x86_32", "arm64", "arm32", "rv64", "ppc64", "loongarch64", "wasm64", and "wasm32".
To detect whether the current build is 64-bit, or the type of architecture, don't use the architecture name. Instead, use OS.HasFeature to check for the "64" feature tag, or tags such as "x86" or "arm". See the Feature Tags documentation for more details.
Note: This method does not return the name of the system's CPU architecture (like OS.GetProcessorName). For example, when running an x86_32 Reckfell binary on an x86_64 system, the returned value will still be "x86_32".
stringGetAuthorInfoReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetAuthorInfo();Returns the engine author information as a Reckfell.Collections.Dictionary, where each entry is an Reckfell.Collections.Array of strings with the names of notable contributors to the Reckfell Engine: lead_developers, founders, project_managers, and developers.
Reckfell.Collections.DictionaryGetCopyrightInfoReckfell.Collections.Array<Reckfell.Collections.Dictionary>
public static Reckfell.Collections.Array<Reckfell.Collections.Dictionary> GetCopyrightInfo();Returns an Reckfell.Collections.Array of dictionaries with copyright information for every component of Reckfell's source code.
Every Reckfell.Collections.Dictionary contains a name identifier, and a parts array of dictionaries. It describes the component in detail with the following entries:
files-Reckfell.Collections.Arrayof file paths from the source code affected by this component;copyright-Reckfell.Collections.Arrayof owners of this component;license- The license applied to this component (such as "Expat(https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants)" or "CC-BY-4.0").
Reckfell.Collections.Array<Reckfell.Collections.Dictionary>GetDonorInfoReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetDonorInfo();Returns a Reckfell.Collections.Dictionary of categorized donor names. Each entry is an Reckfell.Collections.Array of strings:
{platinum_sponsors, gold_sponsors, silver_sponsors, bronze_sponsors, mini_sponsors, gold_donors, silver_donors, bronze_donors}
Reckfell.Collections.DictionaryGetFramesDrawnint
public static int GetFramesDrawn();Returns the total number of frames drawn since the engine started.
Note: On headless platforms, or if rendering is disabled with --disable-render-loop via command line, this method always returns 0. See also Engine.GetProcessFrames.
intGetFramesPerSeconddouble
public static double GetFramesPerSecond();Returns the average frames rendered every second (FPS), also known as the framerate.
doubleGetLicenseInfoReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetLicenseInfo();Returns a Reckfell.Collections.Dictionary of licenses used by Reckfell and included third party components. Each entry is a license name (such as "Expat(https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants)") and its associated text.
Reckfell.Collections.DictionaryGetLicenseTextstring
public static string GetLicenseText();Returns the full Reckfell license text.
stringGetMainLoopMainLoop
public static MainLoop GetMainLoop();Returns the instance of the MainLoop. This is usually the main EntityTree and is the same as Entity.GetTree.
Note: The type instantiated as the main loop can changed with ProjectSettings.application/run/main_loop_type.
MainLoopGetMaxFpsint
public static int GetMaxFps();intGetMaxPhysicsStepsPerFrameint
public static int GetMaxPhysicsStepsPerFrame();intGetPhysicsFramesulong
public static ulong GetPhysicsFrames();Returns the total number of frames passed since the engine started. This number is increased every physics frame. See also Engine.GetProcessFrames.
This method can be used to run expensive logic less often without relying on a Timer:
public override void _PhysicsProcess(double delta)
{
base._PhysicsProcess(delta);
if (Engine.GetPhysicsFrames() % 2 == 0)
{
// Run expensive logic only once every 2 physics frames here.
}
}ulongGetPhysicsInterpolationFractiondouble
public static double GetPhysicsInterpolationFraction();The between-tick fraction for an intermediate rendered pose. Used with retained previous/current state; it neither improves physics accuracy by itself nor measures input latency.
doubleGetPhysicsJitterFixdouble
public static double GetPhysicsJitterFix();doubleGetPhysicsTicksPerSecondint
public static int GetPhysicsTicksPerSecond();intGetProcessFramesulong
public static ulong GetProcessFrames();Returns the total number of frames passed since the engine started. This number is increased every process frame, regardless of whether the render loop is enabled. See also Engine.GetFramesDrawn and Engine.GetPhysicsFrames.
This method can be used to run expensive logic less often without relying on a Timer:
public override void _Process(double delta)
{
base._Process(delta);
if (Engine.GetProcessFrames() % 5 == 0)
{
// Run expensive logic only once every 5 process (render) frames here.
}
}ulongGetScriptLanguageScriptLanguage
public static ScriptLanguage GetScriptLanguage(int index);Returns an instance of a ScriptLanguage with the given index.
| Name | Type | Default |
|---|---|---|
index | int | — |
ScriptLanguageGetScriptLanguageCountint
public static int GetScriptLanguageCount();Returns the number of available script languages. Use with Engine.GetScriptLanguage.
intGetSingletonReckfellObject
public static ReckfellObject GetSingleton(StringName name);Returns the global singleton with the given name, or null if it does not exist. Often used for plugins. See also Engine.HasSingleton and Engine.GetSingletonList.
Note: Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
ReckfellObjectGetSingletonListstring[]
public static string[] GetSingletonList();Returns a list of names of all available global singletons. See also Engine.GetSingleton.
string[]GetTimeScaledouble
public static double GetTimeScale();doubleGetVersionInfoReckfell.Collections.Dictionary
public static Reckfell.Collections.Dictionary GetVersionInfo();Returns the current engine version information as a Reckfell.Collections.Dictionary containing the following entries:
major- Major version number as an int;minor- Minor version number as an int;patch- Patch version number as an int;hex- Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below);status- Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String;build- Build name (e.g. "custom_build") as a String;hash- Full Git commit hash as a String;timestamp- Holds the Git commit date UNIX timestamp in seconds as an int, or0if unavailable;versionandstring- The publicmajor.minor.patchrelease version, including a zero patch. Build configuration and Git identity are separate diagnostic fields. Thehexvalue is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be0x03010C. Note: Thehexvalue is still an [int] internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for quick version comparisons from code:
if ((int)Engine.GetVersionInfo()["hex"] >= 0x040100)
{
// Do things specific to version 4.1 or later.
}
else
{
// Do things specific to versions before 4.1.
}Reckfell.Collections.DictionaryGetWriteMoviePathstring
public static string GetWriteMoviePath();Returns the path to the MovieWriter's output file, or an empty string if the engine wasn't started in Movie Maker mode. The default path can be changed in ProjectSettings.editor/movie_writer/movie_file.
stringHasSingletonbool
public static bool HasSingleton(StringName name);Returns true if a singleton with the given name exists in the global scope. See also Engine.GetSingleton.
ReckfellApi.Print(Engine.HasSingleton("OS")); // Prints True
ReckfellApi.Print(Engine.HasSingleton("Engine")); // Prints True
ReckfellApi.Print(Engine.HasSingleton("AudioServer")); // Prints True
ReckfellApi.Print(Engine.HasSingleton("Unknown")); // Prints FalseNote: Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
boolIsEditorHintbool
public static bool IsEditorHint();Returns true if the script is currently running inside the editor, otherwise returns false. This is useful for @tool scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor:
if (Engine.IsEditorHint())
DrawGizmos();
else
SimulatePhysics();See Running code in the editor in the documentation for more information.
Note: To detect whether the script is running on an editor build (such as when pressing OS.HasFeature with the "editor" argument instead. OS.has_feature("editor") evaluate to true both when the script is running in the editor and when running the project from the editor, but returns false when run from an exported project.
boolIsEmbeddedInEditorbool
public static bool IsEmbeddedInEditor();Returns true if the engine is running embedded in the editor. This is useful to prevent attempting to update window mode or window flags that are not supported when running the project embedded in the editor.
boolIsInPhysicsFramebool
public static bool IsInPhysicsFrame();Returns true if the engine is inside the fixed physics process step of the main loop.
boolIsPrintingErrorMessagesbool
public static bool IsPrintingErrorMessages();boolIsPrintingToStdOutbool
public static bool IsPrintingToStdOut();boolRegisterScriptLanguageError
public static Error RegisterScriptLanguage(ScriptLanguage language);Registers a ScriptLanguage instance to be available with ScriptServer.
Returns:
OKon success;ERR_UNAVAILABLEifScriptServerhas reached the limit and cannot register any new language;ERR_ALREADY_EXISTSifScriptServeralready contains a language with similar extension/name/type.
| Name | Type | Default |
|---|---|---|
language | ScriptLanguage | — |
ErrorRegisterSingletonvoid
public static void RegisterSingleton(StringName name, ReckfellObject instance);Registers the given ReckfellObject instance as a singleton, available globally under name. Useful for plugins.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
instance | ReckfellObject | — |
SetMaxFpsvoid
public static void SetMaxFps(int maxFps);| Name | Type | Default |
|---|---|---|
maxFps | int | — |
SetMaxPhysicsStepsPerFramevoid
public static void SetMaxPhysicsStepsPerFrame(int maxPhysicsSteps);| Name | Type | Default |
|---|---|---|
maxPhysicsSteps | int | — |
SetPhysicsJitterFixvoid
public static void SetPhysicsJitterFix(double physicsJitterFix);| Name | Type | Default |
|---|---|---|
physicsJitterFix | double | — |
SetPhysicsTicksPerSecondvoid
public static void SetPhysicsTicksPerSecond(int physicsTicksPerSecond);| Name | Type | Default |
|---|---|---|
physicsTicksPerSecond | int | — |
SetPrintErrorMessagesvoid
public static void SetPrintErrorMessages(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetPrintToStdOutvoid
public static void SetPrintToStdOut(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetTimeScalevoid
public static void SetTimeScale(double timeScale);| Name | Type | Default |
|---|---|---|
timeScale | double | — |
UnregisterScriptLanguageError
public static Error UnregisterScriptLanguage(ScriptLanguage language);Unregisters the ScriptLanguage instance from ScriptServer.
Returns:
OKon success;ERR_DOES_NOT_EXISTif the language is not registered inScriptServer.
| Name | Type | Default |
|---|---|---|
language | ScriptLanguage | — |
ErrorUnregisterSingletonvoid
public static void UnregisterSingleton(StringName name);Removes the singleton registered under name. The singleton object is not freed. Only works with user-defined singletons registered with Engine.RegisterSingleton.
| Name | Type | Default |
|---|---|---|
name | StringName | — |