WebXR is an open standard that allows creating VR and AR applications that run in the web browser.

As such, this interface is only available when running in an HTML5 export.

WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones).

Since WebXR is based on Javascript, it makes extensive use of callbacks, which means that godot.WebXRInterface is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes godot.WebXRInterface quite a bit more complicated to initialize than other AR/VR interfaces.

Here's the minimum code required to start an immersive VR session:


extends Spatial

var webxr_interface
var vr_supported = false

func _ready():
# We assume this node has a button as a child.
# This button is for the user to consent to entering immersive VR mode.
$Button.connect("pressed", self, "_on_Button_pressed")

webxr_interface = ARVRServer.find_interface("WebXR")
if webxr_interface:
# WebXR uses a lot of asynchronous callbacks, so we connect to various
# signals in order to receive them.
webxr_interface.connect("session_supported", self, "_webxr_session_supported")
webxr_interface.connect("session_started", self, "_webxr_session_started")
webxr_interface.connect("session_ended", self, "_webxr_session_ended")
webxr_interface.connect("session_failed", self, "_webxr_session_failed")

# This returns immediately - our _webxr_session_supported() method
# (which we connected to the "session_supported" signal above) will
# be called sometime later to let us know if it's supported or not.
webxr_interface.is_session_supported("immersive-vr")

func _webxr_session_supported(session_mode, supported):
if session_mode == 'immersive-vr':
vr_supported = supported

func _on_Button_pressed():
if not vr_supported:
OS.alert("Your browser doesn't support VR")
return

# We want an immersive VR session, as opposed to AR ('immersive-ar') or a
# simple 3DoF viewer ('viewer').
webxr_interface.session_mode = 'immersive-vr'
# 'bounded-floor' is room scale, 'local-floor' is a standing or sitting
# experience (it puts you 1.6m above the ground if you have 3DoF headset),
# whereas as 'local' puts you down at the ARVROrigin.
# This list means it'll first try to request 'bounded-floor', then
# fallback on 'local-floor' and ultimately 'local', if nothing else is
# supported.
webxr_interface.requested_reference_space_types = 'bounded-floor, local-floor, local'
# In order to use 'local-floor' or 'bounded-floor' we must also
# mark the features as required or optional.
webxr_interface.required_features = 'local-floor'
webxr_interface.optional_features = 'bounded-floor'

# This will return false if we're unable to even request the session,
# however, it can still fail asynchronously later in the process, so we
# only know if it's really succeeded or failed when our
# _webxr_session_started() or _webxr_session_failed() methods are called.
if not webxr_interface.initialize():
OS.alert("Failed to initialize")
return

func _webxr_session_started():
$Button.visible = false
# This tells Godot to start rendering to the headset.
get_viewport().arvr = true
# This will be the reference space type you ultimately got, out of the
# types that you requested above. This is useful if you want the game to
# work a little differently in 'bounded-floor' versus 'local-floor'.
print ("Reference space type: " + webxr_interface.reference_space_type)

func _webxr_session_ended():
$Button.visible = true
# If the user exits immersive mode, then we tell Godot to render to the web
# page again.
get_viewport().arvr = false

func _webxr_session_failed(message):
OS.alert("Failed to initialize: " + message)

There are several ways to handle "controller" input:

You can use one or all of these methods to allow your game or app to support a wider or narrower set of devices and input methods, or to allow more advanced interations with more advanced devices.

Variables

@:native("BoundsGeometry")read onlyboundsGeometry:NativeArray<Vector3>

The vertices of a polygon which defines the boundaries of the user's play area.

This will only be available if godot.WebXRInterface.referenceSpaceType is "bounded-floor" and only on certain browsers and devices that support it.

The reference_space_reset signal may indicate when this changes.

read onlyonReferenceSpaceReset:Signal<() ‑> Void>

reference_space_reset signal.

read onlyonSelect:Signal<(controllerId:Int) ‑> Void>

select signal.

read onlyonSelectend:Signal<(controllerId:Int) ‑> Void>

selectend signal.

read onlyonSelectstart:Signal<(controllerId:Int) ‑> Void>

selectstart signal.

read onlyonSessionEnded:Signal<() ‑> Void>

session_ended signal.

read onlyonSessionFailed:Signal<(message:String) ‑> Void>

session_failed signal.

read onlyonSessionStarted:Signal<() ‑> Void>

session_started signal.

read onlyonSessionSupported:Signal<(sessionMode:String, supported:Bool) ‑> Void>

session_supported signal.

read onlyonSqueeze:Signal<(controllerId:Int) ‑> Void>

squeeze signal.

read onlyonSqueezeend:Signal<(controllerId:Int) ‑> Void>

squeezeend signal.

read onlyonSqueezestart:Signal<(controllerId:Int) ‑> Void>

squeezestart signal.

read onlyonVisibilityStateChanged:Signal<() ‑> Void>

visibility_state_changed signal.

@:native("OptionalFeatures")optionalFeatures:String

A comma-seperated list of optional features used by godot.ARVRInterface.initialize when setting up the WebXR session.

If a user's browser or device doesn't support one of the given features, initialization will continue, but you won't be able to use the requested feature.

This doesn't have any effect on the interface when already initialized.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType](WebXR's XRReferenceSpaceType). If you want to use a particular reference space type, it must be listed in either godot.WebXRInterface.requiredFeatures or godot.WebXRInterface.optionalFeatures.

@:native("ReferenceSpaceType")read onlyreferenceSpaceType:String

The reference space type (from the list of requested types set in the godot.WebXRInterface.requestedReferenceSpaceTypes property), that was ultimately used by godot.ARVRInterface.initialize when setting up the WebXR session.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType](WebXR's XRReferenceSpaceType). If you want to use a particular reference space type, it must be listed in either godot.WebXRInterface.requiredFeatures or godot.WebXRInterface.optionalFeatures.

@:native("RequestedReferenceSpaceTypes")requestedReferenceSpaceTypes:String

A comma-seperated list of reference space types used by godot.ARVRInterface.initialize when setting up the WebXR session.

The reference space types are requested in order, and the first on supported by the users device or browser will be used. The godot.WebXRInterface.referenceSpaceType property contains the reference space type that was ultimately used.

This doesn't have any effect on the interface when already initialized.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType](WebXR's XRReferenceSpaceType). If you want to use a particular reference space type, it must be listed in either godot.WebXRInterface.requiredFeatures or godot.WebXRInterface.optionalFeatures.

@:native("RequiredFeatures")requiredFeatures:String

A comma-seperated list of required features used by godot.ARVRInterface.initialize when setting up the WebXR session.

If a user's browser or device doesn't support one of the given features, initialization will fail and session_failed will be emitted.

This doesn't have any effect on the interface when already initialized.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType](WebXR's XRReferenceSpaceType). If you want to use a particular reference space type, it must be listed in either godot.WebXRInterface.requiredFeatures or godot.WebXRInterface.optionalFeatures.

@:native("SessionMode")sessionMode:String

The session mode used by godot.ARVRInterface.initialize when setting up the WebXR session.

This doesn't have any effect on the interface when already initialized.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode](WebXR's XRSessionMode), including: "immersive-vr", "immersive-ar", and "inline".

@:native("VisibilityState")read onlyvisibilityState:String

Indicates if the WebXR session's imagery is visible to the user.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRVisibilityState](WebXR's XRVisibilityState), including "hidden", "visible", and "visible-blurred".

Methods

inlinegetBoundsGeometry():Array<Vector3>

@:native("GetController")getController(controllerId:Int):ARVRPositionalTracker

Gets an godot.ARVRPositionalTracker for the given controller_id.

In the context of WebXR, a "controller" can be an advanced VR controller like the Oculus Touch or Index controllers, or even a tap on the screen, a spoken voice command or a button press on the device itself. When a non-traditional controller is used, interpret the position and orientation of the godot.ARVRPositionalTracker as a ray pointing at the object the user wishes to interact with.

Use this method to get information about the controller that triggered one of these signals:

  • selectstart

  • select

  • selectend

  • squeezestart

  • squeeze

  • squeezestart

@:native("GetOptionalFeatures")getOptionalFeatures():String

@:native("GetReferenceSpaceType")getReferenceSpaceType():String

@:native("GetRequestedReferenceSpaceTypes")getRequestedReferenceSpaceTypes():String

@:native("GetRequiredFeatures")getRequiredFeatures():String

@:native("GetSessionMode")getSessionMode():String

@:native("GetVisibilityState")getVisibilityState():String

@:native("IsSessionSupported")isSessionSupported(sessionMode:String):Void

Checks if the given session_mode is supported by the user's browser.

Possible values come from [https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode](WebXR's XRSessionMode), including: "immersive-vr", "immersive-ar", and "inline".

This method returns nothing, instead it emits the session_supported signal with the result.

@:native("SetOptionalFeatures")setOptionalFeatures(optionalFeatures:String):Void

@:native("SetRequestedReferenceSpaceTypes")setRequestedReferenceSpaceTypes(requestedReferenceSpaceTypes:String):Void

@:native("SetRequiredFeatures")setRequiredFeatures(requiredFeatures:String):Void

@:native("SetSessionMode")setSessionMode(sessionMode:String):Void

Inherited Variables

Defined by ARVRInterface

@:native("ArIsAnchorDetectionEnabled")arIsAnchorDetectionEnabled:Bool

On an AR interface, true if anchor detection is enabled.

@:native("InterfaceIsInitialized")interfaceIsInitialized:Bool

true if this interface been initialized.

@:native("InterfaceIsPrimary")interfaceIsPrimary:Bool

true if this is the primary interface.

Defined by Object

@:native("DynamicObject")read onlydynamicObject:Dynamic

Gets a new godot.DynamicGodotObject associated with this instance.

@:native("NativeInstance")read onlynativeInstance:IntPtr

The pointer to the native instance of this godot.Object.

read onlyonScriptChanged:Signal<() ‑> Void>

script_changed signal.

Inherited Methods

Defined by ARVRInterface

@:native("GetAnchorDetectionIsEnabled")getAnchorDetectionIsEnabled():Bool

@:native("GetCameraFeedId")getCameraFeedId():Int

If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the godot.CameraServer for this interface.

@:native("GetCapabilities")getCapabilities():Int

Returns a combination of godot.ARVRInterface_Capabilities flags providing information about the capabilities of this interface.

@:native("GetName")getName():String

Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc).

@:native("GetRenderTargetsize")getRenderTargetsize():Vector2

Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.

@:native("GetTrackingStatus")getTrackingStatus():ARVRInterface_Tracking_status

If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.

@:native("Initialize")initialize():Bool

Call this to initialize this interface. The first interface that is initialized is identified as the primary interface and it will be used for rendering output.

After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.

Note: You must enable the AR/VR mode on the main viewport for any device that uses the main output of Godot, such as for mobile VR.

If you do this for a platform that handles its own output (such as OpenVR) Godot will show just one eye without distortion on screen. Alternatively, you can add a separate viewport node to your scene and enable AR/VR on that viewport. It will be used to output to the HMD, leaving you free to do anything you like in the main window, such as using a separate camera as a spectator camera or rendering something completely different.

While currently not used, you can activate additional interfaces. You may wish to do this if you want to track controllers from other platforms. However, at this point in time only one interface can render to an HMD.

@:native("IsInitialized")isInitialized():Bool

@:native("IsPrimary")isPrimary():Bool

@:native("IsStereo")isStereo():Bool

Returns true if the current output of this interface is in stereo.

@:native("SetAnchorDetectionIsEnabled")setAnchorDetectionIsEnabled(enable:Bool):Void

@:native("SetIsInitialized")setIsInitialized(initialized:Bool):Void

@:native("SetIsPrimary")setIsPrimary(enable:Bool):Void

@:native("Uninitialize")uninitialize():Void

Turns the interface off.

Defined by Reference

@:native("InitRef")initRef():Bool

Initializes the internal reference counter. Use this only if you really know what you are doing.

Returns whether the initialization was successful.

@:native("Reference_")reference_():Bool

Increments the internal reference counter. Use this only if you really know what you are doing.

Returns true if the increment was successful, false otherwise.

@:native("Unreference")unreference():Bool

Decrements the internal reference counter. Use this only if you really know what you are doing.

Returns true if the decrement was successful, false otherwise.

Defined by Object

@:native("_Get")_Get(property:String):Dynamic

Virtual method which can be overridden to customize the return value of godot.Object.get.

Returns the given property. Returns null if the property does not exist.

@:native("_GetPropertyList")_GetPropertyList():Array

Virtual method which can be overridden to customize the return value of godot.Object.getPropertyList.

Returns the object's property list as an godot.Collections_Array of dictionaries.

Each property's godot.Collections_Dictionary must contain at least name: String and type: int (see godot.Variant_Type) entries. Optionally, it can also include hint: int (see godot.PropertyHint), hint_string: String, and usage: int (see godot.PropertyUsageFlags).

@:native("_Notification")_Notification(what:Int):Void

Called whenever the object receives a notification, which is identified in what by a constant. The base godot.Object has two constants godot.Object.notificationPostinitialize and godot.Object.notificationPredelete, but subclasses such as godot.Node define a lot more notifications which are also received by this method.

@:native("_Set")_Set(property:String, value:Dynamic):Bool

Virtual method which can be overridden to customize the return value of godot.Object.set.

Sets a property. Returns true if the property exists.

@:native("AddUserSignal")addUserSignal(signal:String, ?arguments:Array):Void

Adds a user-defined signal. Arguments are optional, but can be added as an godot.Collections_Array of dictionaries, each containing name: String and type: int (see godot.Variant_Type) entries.

Parameters:

arguments

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("Call")call(method:String, args:HaxeArray<Dynamic>):Dynamic

Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:


call("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

@:native("CallDeferred")callDeferred(method:String, args:HaxeArray<Dynamic>):Void

Calls the method on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:


call_deferred("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

@:native("Callv")callv(method:String, argArray:Array):Dynamic

Calls the method on the object and returns the result. Contrarily to godot.Object.call, this method does not support a variable number of arguments but expects all parameters to be via a single godot.Collections_Array.


callv("set", [ "position", Vector2(42.0, 0.0) ])

@:native("CanTranslateMessages")canTranslateMessages():Bool

Returns true if the object can translate strings. See godot.Object.setMessageTranslation and godot.Object.tr.

@:native("Connect")connect(signal:String, target:Object, method:String, ?binds:Array, ?flags:UInt):Error

Connects a signal to a method on a target object. Pass optional binds to the call as an godot.Collections_Array of parameters. These parameters will be passed to the method after any parameter used in the call to godot.Object.emitSignal. Use flags to set deferred or one-shot connections. See godot.Object_ConnectFlags constants.

A signal can only be connected once to a method. It will print an error if already connected, unless the signal was connected with godot.Object_ConnectFlags.referenceCounted. To avoid this, first, use godot.Object.isConnected to check for existing connections.

If the target is destroyed in the game's lifecycle, the connection will be lost.

Examples:


connect("pressed", self, "_on_Button_pressed") # BaseButton signal
connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal
connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal

An example of the relationship between binds passed to godot.Object.connect and parameters used when calling godot.Object.emitSignal:


connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # weapon_type and damage are passed last
emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first
func _on_Player_hit(hit_by, level, weapon_type, damage):
print("Hit by %s (lvl %d) with weapon %s for %d damage" % [hit_by, level, weapon_type, damage])

Parameters:

binds

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("Disconnect")disconnect(signal:String, target:Object, method:String):Void

Disconnects a signal from a method on the given target.

If you try to disconnect a connection that does not exist, the method will print an error. Use godot.Object.isConnected to ensure that the connection exists.

@:native("Dispose")dispose():Void

@:native("Dispose")@:protectedDispose(disposing:Bool):Void

Disposes of this godot.Object.

@:native("EmitSignal")emitSignal(signal:String, args:HaxeArray<Dynamic>):Void

Emits the given signal. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:


emit_signal("hit", weapon_type, damage)
emit_signal("game_over")

@:native("Free")free():Void

Deletes the object from memory immediately. For godot.Nodes, you may want to use godot.Node.queueFree to queue the node for safe deletion at the end of the current frame.

Important: If you have a variable pointing to an object, it will not be assigned to null once the object is freed. Instead, it will point to a previously freed instance and you should validate it with @GDScript.is_instance_valid before attempting to call its methods or access its properties.

@:native("Get")get(property:String):Dynamic

Returns the Variant value of the given property. If the property doesn't exist, this will return null.

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

@:native("GetClass")getClass():String

Returns the object's class as a String. See also godot.Object.isClass.

Note: godot.Object.getClass does not take class_name declarations into account. If the object has a class_name defined, the base class name will be returned instead.

@:native("GetIncomingConnections")getIncomingConnections():Array

Returns an godot.Collections_Array of dictionaries with information about signals that are connected to the object.

Each godot.Collections_Dictionary contains three String entries:

  • source is a reference to the signal emitter.

  • signal_name is the name of the connected signal.

  • method_name is the name of the method to which the signal is connected.

@:native("GetIndexed")getIndexed(property:NodePath):Dynamic

Gets the object's property indexed by the given godot.NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Examples: "position:x" or "material:next_pass:blend_mode".

Note: Even though the method takes godot.NodePath argument, it doesn't support actual paths to godot.Nodes in the scene tree, only colon-separated sub-property paths. For the purpose of nodes, use godot.Node.getNodeAndResource instead.

@:native("GetInstanceId")getInstanceId():UInt64

Returns the object's unique instance ID.

This ID can be saved in godot.EncodedObjectAsID, and can be used to retrieve the object instance with @GDScript.instance_from_id.

@:native("GetMeta")getMeta(name:String):Dynamic

Returns the object's metadata entry for the given name.

inlinegetMetaList():Array<String>

Returns the object's metadata as a String.

@:native("GetMethodList")getMethodList():Array

Returns the object's methods and their signatures as an godot.Collections_Array.

@:native("GetPropertyList")getPropertyList():Array

Returns the object's property list as an godot.Collections_Array of dictionaries.

Each property's godot.Collections_Dictionary contain at least name: String and type: int (see godot.Variant_Type) entries. Optionally, it can also include hint: int (see godot.PropertyHint), hint_string: String, and usage: int (see godot.PropertyUsageFlags).

@:native("GetScript")getScript():Reference

Returns the object's godot.Script instance, or null if none is assigned.

@:native("GetSignalConnectionList")getSignalConnectionList(signal:String):Array

Returns an godot.Collections_Array of connections for the given signal.

@:native("GetSignalList")getSignalList():Array

Returns the list of signals as an godot.Collections_Array of dictionaries.

@:native("HasMeta")hasMeta(name:String):Bool

Returns true if a metadata entry is found with the given name.

@:native("HasMethod")hasMethod(method:String):Bool

Returns true if the object contains the given method.

@:native("HasSignal")hasSignal(signal:String):Bool

Returns true if the given signal exists.

@:native("HasUserSignal")hasUserSignal(signal:String):Bool

Returns true if the given user-defined signal exists. Only signals added using godot.Object.addUserSignal are taken into account.

@:native("IsBlockingSignals")isBlockingSignals():Bool

Returns true if signal emission blocking is enabled.

@:native("IsClass")isClass(class_:String):Bool

Returns true if the object inherits from the given class. See also godot.Object.getClass.

Note: godot.Object.isClass does not take class_name declarations into account. If the object has a class_name defined, godot.Object.isClass will return false for that name.

@:native("IsConnected")isConnected(signal:String, target:Object, method:String):Bool

Returns true if a connection exists for a given signal, target, and method.

@:native("IsQueuedForDeletion")isQueuedForDeletion():Bool

Returns true if the godot.Node.queueFree method was called for the object.

@:native("Notification")notification(what:Int, ?reversed:Bool):Void

Send a given notification to the object, which will also trigger a call to the godot.Object._Notification method of all classes that the object inherits from.

If reversed is true, godot.Object._Notification is called first on the object's own class, and then up to its successive parent classes. If reversed is false, godot.Object._Notification is called first on the highest ancestor (godot.Object itself), and then down to its successive inheriting classes.

@:native("PropertyListChangedNotify")propertyListChangedNotify():Void

Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.

@:native("RemoveMeta")removeMeta(name:String):Void

Removes a given entry from the object's metadata. See also godot.Object.setMeta.

@:native("Set")set(property:String, value:Dynamic):Void

Assigns a new value to the given property. If the property does not exist or the given value's type doesn't match, nothing will happen.

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

@:native("SetBlockSignals")setBlockSignals(enable:Bool):Void

If set to true, signal emission is blocked.

@:native("SetDeferred")setDeferred(property:String, value:Dynamic):Void

Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling godot.Object.set via godot.Object.callDeferred, i.e. call_deferred("set", property, value).

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

@:native("SetIndexed")setIndexed(property:NodePath, value:Dynamic):Void

Assigns a new value to the property identified by the godot.NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Example:


set_indexed("position", Vector2(42, 0))
set_indexed("position:y", -10)
print(position) # (42, -10)

@:native("SetMessageTranslation")setMessageTranslation(enable:Bool):Void

Defines whether the object can translate strings (with calls to godot.Object.tr). Enabled by default.

@:native("SetMeta")setMeta(name:String, value:Dynamic):Void

Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any Variant value.

To remove a given entry from the object's metadata, use godot.Object.removeMeta. Metadata is also removed if its value is set to null. This means you can also use set_meta("name", null) to remove metadata for "name".

@:native("SetScript")setScript(script:Reference):Void

Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.

If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's method will be called.

@:native("ToSignal")toSignal(source:Object, signal:String):SignalAwaiter

Returns a new godot.SignalAwaiter awaiter configured to complete when the instance source emits the signal specified by the signal parameter.

Parameters:

source

The instance the awaiter will be listening to.

signal

The signal the awaiter will be waiting for. This sample prints a message once every frame up to 100 times.

public override void _Ready()
{
for (int i = 0; i &lt; 100; i++)
{
await ToSignal(GetTree(), "idle_frame");
GD.Print($"Frame {i}");
}
}

Returns:

A godot.SignalAwaiter that completes when source emits the signal.

@:native("ToString")toString():String

Converts this godot.Object to a string.

Returns:

A string representation of this object.

@:native("Tr")tr(message:String):String

Translates a message using translation catalogs configured in the Project Settings.

Only works if message translation is enabled (which it is by default), otherwise it returns the message unchanged. See godot.Object.setMessageTranslation.