Engine
Provides access to engine properties.
Engine.swift:11class Engine
The Engine
singleton allows you to query and modify the project’s run-time parameters, such as frames per second, time scale, and others.
Superclasses
class Object
Base class for all other classes in the engine.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
static var maxFps: Int32
The maximum number of frames per second that can be rendered. A value of
0
means “no limit”. The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project logic and rendering.static var maxPhysicsStepsPerFrame: Int32
Controls the maximum number of physics steps that can be simulated each rendered frame. The default value is tuned to avoid “spiral of death” situations where expensive physics simulations trigger 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
ofphysicsTicksPerSecond
. This occurs even ifdelta
is consistently used in physics calculations. To avoid this, increasemaxPhysicsStepsPerFrame
if you have increasedphysicsTicksPerSecond
significantly above its default value.static var physicsJitterFix: Double
Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
static var physicsTicksPerSecond: Int32
The number of fixed iterations per second. This controls how often physics simulation and
_physicsProcess(delta:)
methods are run. This value should generally always be set to60
or above, as Godot doesn’t interpolate the physics step. As a result, values lower than60
will look stuttery. This value can be increased to make input more reactive or work around collision tunneling issues, but keep in mind doing so will increase CPU usage. See alsomaxFps
andProjectSettings/physics/common/physicsTicksPerSecond
.static var printErrorMessages: Bool
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 theProjectSettings/application/run/disableStderr
project setting.static var timeScale: Double
Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed. This also affects
Timer
andSceneTreeTimer
(seecreateTimer(timeSec:processAlways:processInPhysics:ignoreTimeScale:)
for how to control this).static func getArchitectureName(
) -> String Returns the name of the CPU architecture the Godot binary was built for. Possible return values are
x86_64
,x86_32
,arm64
,arm32
,rv64
,riscv
,ppc64
,ppc
,wasm64
andwasm32
.static func getAuthorInfo(
) -> GDictionary Returns engine author information in a Dictionary.
static func getCopyrightInfo(
) -> VariantCollection<GDictionary> Returns an Array of copyright information Dictionaries.
static func getDonorInfo(
) -> GDictionary Returns a Dictionary of Arrays of donor names.
static func getFramesDrawn(
) -> Int32 Returns the total number of frames drawn. On headless platforms, or if the render loop is disabled with
--disable-render-loop
via command line,getFramesDrawn
always returns0
. SeegetProcessFrames
.static func getFramesPerSecond(
) -> Double Returns the frames per second of the running game.
static func getLicenseInfo(
) -> GDictionary Returns Dictionary of licenses used by Godot and included third party components.
static func getLicenseText(
) -> String Returns Godot license text.
static func getMainLoop(
) -> MainLoop? Returns the main loop object (see
MainLoop
andSceneTree
).static func getPhysicsFrames(
) -> UInt Returns the total number of frames passed since engine initialization which is advanced on each physics frame. See also
getProcessFrames
.static func getPhysicsInterpolationFraction(
) -> Double Returns the fraction through the current physics tick we are at the time of rendering the frame. This can be used to implement fixed timestep interpolation.
static func getProcessFrames(
) -> UInt Returns the total number of frames passed since engine initialization which is advanced on each process frame, regardless of whether the render loop is enabled. See also
getFramesDrawn
andgetPhysicsFrames
.static func getScriptLanguage(index: Int32
) -> ScriptLanguage? Returns an instance of a
ScriptLanguage
with the given index.static func getScriptLanguageCount(
) -> Int32 Returns the number of available script languages. Use with
getScriptLanguage(index:)
.static func getSingleton(name: StringName
) -> Object? Returns a global singleton with given
name
. Often used for plugins, e.g. GodotPayments.static func getSingletonList(
) -> PackedStringArray Returns a list of available global singletons.
static func getVersionInfo(
) -> GDictionary Returns the current engine version information in a Dictionary.
static func getWriteMoviePath(
) -> String Returns the path to the
MovieWriter
‘s output file, or an empty string if the engine wasn’t started in Movie Maker mode. This path can be absolute or relative depending on how the user specified it.static func hasSingleton(name: StringName
) -> Bool Returns
true
if a singleton with givenname
exists in global scope.static func isEditorHint(
) -> Bool Returns
true
if the script is currently running inside the editor,false
otherwise. 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:static func isInPhysicsFrame(
) -> Bool Returns
true
if the game is inside the fixed process and physics phase of the game loop.static func registerScriptLanguage(ScriptLanguage?
) -> GodotError Registers a
ScriptLanguage
instance to be available withScriptServer
.static func registerSingleton(name: StringName, instance: Object?
) Registers the given object as a singleton, globally available under
name
.static func unregisterScriptLanguage(ScriptLanguage?
) -> GodotError Unregisters the
ScriptLanguage
instance fromScriptServer
.static func unregisterSingleton(name: StringName
) Unregisters the singleton registered under
name
. The singleton object is not freed. Only works with user-defined singletons created withregisterSingleton(name:instance:)
.class var godotClassName: StringName