class CSGMesh
package godot
extends CSGPrimitive › CSGShape › GeometryInstance › VisualInstance › CullInstance › Spatial › Node › Object
@:nativeGen@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:libType@:csNative@:native("Godot.CSGMesh")@:autoBuild(godot.Godot.buildUserClass())This CSG node allows you to use any mesh resource as a CSG shape, provided it is closed, does not self-intersect, does not contain internal faces and has no edges that connect to more than two faces. See also godot.CSGPolygon
for drawing 2D extruded polygons to be used as CSG nodes.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a godot.MeshInstance
with a godot.PrimitiveMesh
. Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
Constructor
Variables
@:native("Mesh")mesh:Mesh
The godot.Mesh
resource to use as a CSG shape.
Note: When using an godot.ArrayMesh
, avoid meshes with vertex normals unless a flat shader is required. By default, CSGMesh will ignore the mesh's vertex normals and use a smooth shader calculated using the faces' normals. If a flat shader is required, ensure that all faces' vertex normals are parallel.
Methods
Inherited Variables
Defined by CSGPrimitive
Defined by CSGShape
@:native("CalculateTangents")calculateTangents:Bool
Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
@:native("CollisionLayer")collisionLayer:UInt
The physics layers this area is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [https://docs.godotengine.org/en/3.4/tutorials/physics/physics_introduction.html#collision-layers-and-masks](Collision layers and masks) in the documentation for more information.
@:native("CollisionMask")collisionMask:UInt
The physics layers this CSG shape scans for collisions. See [https://docs.godotengine.org/en/3.4/tutorials/physics/physics_introduction.html#collision-layers-and-masks](Collision layers and masks) in the documentation for more information.
@:native("Operation")operation:CSGShape_OperationEnum
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
@:native("Snap")snap:Single
Snap makes the mesh snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust.
@:native("UseCollision")useCollision:Bool
Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden.
Defined by GeometryInstance
@:native("CastShadow")castShadow:GeometryInstance_ShadowCastingSetting
The selected shadow casting flag. See godot.GeometryInstance_ShadowCastingSetting
for possible values.
@:native("ExtraCullMargin")extraCullMargin:Single
The extra distance added to the GeometryInstance's bounding box (godot.AABB
) to increase its cull box.
@:native("GenerateLightmap")generateLightmap:Bool
When disabled, the mesh will be taken into account when computing indirect lighting, but the resulting lightmap will not be saved. Useful for emissive only materials or shadow casters.
@:native("LightmapScale")lightmapScale:GeometryInstance_LightmapScaleEnum
Scale factor for the generated baked lightmap. Useful for adding detail to certain mesh instances.
@:native("LodMaxDistance")lodMaxDistance:Single
The GeometryInstance's max LOD distance.
Note: This property currently has no effect.
@:native("LodMaxHysteresis")lodMaxHysteresis:Single
The GeometryInstance's max LOD margin.
Note: This property currently has no effect.
@:native("LodMinDistance")lodMinDistance:Single
The GeometryInstance's min LOD distance.
Note: This property currently has no effect.
@:native("LodMinHysteresis")lodMinHysteresis:Single
The GeometryInstance's min LOD margin.
Note: This property currently has no effect.
@:native("MaterialOverride")materialOverride:Material
The material override for the whole geometry.
If a material is assigned to this property, it will be used instead of any material set in any material slot of the mesh.
@:native("UseInBakedLight")useInBakedLight:Bool
If true
, this GeometryInstance will be used when baking lights using a godot.GIProbe
or godot.BakedLightmap
.
Defined by VisualInstance
@:native("Layers")layers:UInt
The render layer(s) this godot.VisualInstance
is drawn on.
This object will only be visible for godot.Camera
s whose cull mask includes the render object this godot.VisualInstance
is set to.
Defined by CullInstance
@:native("AutoplacePriority")autoplacePriority:Int
When set to 0
, godot.CullInstance
s will be autoplaced in the godot.Room
with the highest priority.
When set to a value other than 0
, the system will attempt to autoplace in a godot.Room
with the autoplace_priority
, if it is present.
This can be used to control autoplacement of building exteriors in an outer godot.RoomGroup
.
@:native("IncludeInBound")includeInBound:Bool
When a manual bound has not been explicitly specified for a godot.Room
, the convex hull bound will be estimated from the geometry of the objects within the room. This setting determines whether the geometry of an object is included in this estimate of the room bound.
Note: This setting is only relevant when the object is set to PORTAL_MODE_STATIC
or PORTAL_MODE_DYNAMIC
, and for godot.Portal
s.
@:native("PortalMode")portalMode:CullInstance_PortalModeEnum
When using godot.Room
s and godot.Portal
s, this specifies how the godot.CullInstance
is processed in the system.
Defined by Spatial
@:native("Gizmo")gizmo:SpatialGizmo
The godot.SpatialGizmo
for this node. Used for example in Godot.EditorSpatialGizmo
as custom visualization and editing handles in Editor.
@:native("GlobalTransform")globalTransform:Transform
World space (global) godot.Transform
of this node.
@:native("Rotation")rotation:Vector3
Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
Note: In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a godot.Vector3
data structure not because the rotation is a vector, but only because godot.Vector3
exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
@:native("RotationDegrees")rotationDegrees:Vector3
Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
@:native("Transform")transform:Transform
Local space godot.Transform
of this node, with respect to the parent node.
@:native("Visible")visible:Bool
If true
, this node is drawn. The node is only visible if all of its antecedents are visible as well (in other words, godot.Spatial.isVisibleInTree
must return true
).
Defined by Node
@:native("CustomMultiplayer")customMultiplayer:MultiplayerAPI
The override to the default godot.MultiplayerAPI
. Set to null
to use the default godot.SceneTree
one.
@:native("Filename")filename:String
If a scene is instantiated from a file, its topmost node contains the absolute file path from which it was loaded in godot.Node.filename
(e.g. res://levels/1.tscn
). Otherwise, godot.Node.filename
is set to an empty string.
@:native("Multiplayer")read onlymultiplayer:MultiplayerAPI
The godot.MultiplayerAPI
instance associated with this node. Either the godot.Node.customMultiplayer
, or the default SceneTree one (if inside tree).
@:native("Name")name:String
The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed.
Note: Auto-generated names might include the @
character, which is reserved for unique names when using godot.Node.addChild
. When setting the name manually, any @
will be removed.
@:native("Owner")owner:Node
The node owner. A node can have any other node as owner (as long as it is a valid parent, grandparent, etc. ascending in the tree). When saving a node (using godot.PackedScene
), all the nodes it owns will be saved with it. This allows for the creation of complex godot.SceneTree
s, with instancing and subinstancing.
Note: If you want a child to be persisted to a godot.PackedScene
, you must set godot.Node.owner
in addition to calling godot.Node.addChild
. This is typically relevant for [https://docs.godotengine.org/en/3.4/tutorials/misc/running_code_in_the_editor.html](tool scripts) and [https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/index.html](editor plugins). If godot.Node.addChild
is called without setting godot.Node.owner
, the newly added godot.Node
will not be visible in the scene tree, though it will be visible in the 2D/3D view.
@:native("PauseMode")pauseMode:Node_PauseModeEnum
Pause mode. How the node will behave if the godot.SceneTree
is paused.
@:native("ProcessPriority")processPriority:Int
The node's priority in the execution order of the enabled processing callbacks (i.e. godot.Node.notificationProcess
, godot.Node.notificationPhysicsProcess
and their internal counterparts). Nodes whose process priority value is lower will have their processing callbacks executed first.
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
.
Inherited Methods
Defined by CSGPrimitive
Defined by CSGShape
@:native("GetCollisionLayerBit")getCollisionLayerBit(bit:Int):Bool
Returns an individual bit on the collision mask.
@:native("GetCollisionMaskBit")getCollisionMaskBit(bit:Int):Bool
Returns an individual bit on the collision mask.
@:native("GetMeshes")getMeshes():Array
Returns an godot.Collections_Array
with two elements, the first is the godot.Transform
of this node and the second is the root godot.Mesh
of this node. Only works when this node is the root shape.
@:native("IsRootShape")isRootShape():Bool
Returns true
if this is a root shape and is thus the object that is rendered.
@:native("SetCollisionLayerBit")setCollisionLayerBit(bit:Int, value:Bool):Void
Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
@:native("SetCollisionMaskBit")setCollisionMaskBit(bit:Int, value:Bool):Void
Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
Defined by GeometryInstance
@:native("GetFlag")getFlag(flag:GeometryInstance_Flags):Bool
Returns the godot.GeometryInstance_Flags
that have been set for this object.
@:native("SetCastShadowsSetting")setCastShadowsSetting(shadowCastingSetting:GeometryInstance_ShadowCastingSetting):Void
@:native("SetCustomAabb")setCustomAabb(aabb:AABB):Void
Overrides the bounding box of this node with a custom one. To remove it, set an godot.AABB
with all fields set to zero.
@:native("SetFlag")setFlag(flag:GeometryInstance_Flags, value:Bool):Void
Sets the godot.GeometryInstance_Flags
specified. See godot.GeometryInstance_Flags
for options.
Defined by VisualInstance
@:native("GetAabb")getAabb():AABB
Returns the godot.AABB
(also known as the bounding box) for this godot.VisualInstance
. See also godot.VisualInstance.getTransformedAabb
.
@:native("GetBase")getBase():RID
Returns the RID of the resource associated with this godot.VisualInstance
. For example, if the Node is a godot.MeshInstance
, this will return the RID of the associated godot.Mesh
.
@:native("GetInstance")getInstance():RID
Returns the RID of this instance. This RID is the same as the RID returned by godot.VisualServer.instanceCreate
. This RID is needed if you want to call godot.VisualServer
functions directly on this godot.VisualInstance
.
@:native("GetLayerMaskBit")getLayerMaskBit(layer:Int):Bool
Returns true
when the specified layer is enabled in godot.VisualInstance.layers
and false
otherwise.
@:native("GetTransformedAabb")getTransformedAabb():AABB
Returns the transformed godot.AABB
(also known as the bounding box) for this godot.VisualInstance
.
Transformed in this case means the godot.AABB
plus the position, rotation, and scale of the godot.Spatial
's godot.Transform
. See also godot.VisualInstance.getAabb
.
@:native("SetBase")setBase(base:RID):Void
Sets the resource that is instantiated by this godot.VisualInstance
, which changes how the engine handles the godot.VisualInstance
under the hood. Equivalent to godot.VisualServer.instanceSetBase
.
@:native("SetLayerMaskBit")setLayerMaskBit(layer:Int, enabled:Bool):Void
Enables a particular layer in godot.VisualInstance.layers
.
Defined by CullInstance
Defined by Spatial
@:native("ForceUpdateTransform")forceUpdateTransform():Void
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
@:native("GetParentSpatial")getParentSpatial():Spatial
Returns the parent godot.Spatial
, or an empty godot.Object
if no parent exists or parent is not of type godot.Spatial
.
@:native("GetWorld")getWorld():World
Returns the current godot.World
resource this godot.Spatial
node is registered to.
@:native("GlobalRotate")globalRotate(axis:Vector3, angle:Single):Void
Rotates the global (world) transformation around axis, a unit godot.Vector3
, by specified angle in radians. The rotation axis is in global coordinate system.
@:native("GlobalScale")globalScale(scale:Vector3):Void
Scales the global (world) transformation by the given godot.Vector3
scale factors.
@:native("GlobalTranslate")globalTranslate(offset:Vector3):Void
Moves the global (world) transformation by godot.Vector3
offset. The offset is in global coordinate system.
@:native("IsLocalTransformNotificationEnabled")isLocalTransformNotificationEnabled():Bool
Returns whether node notifies about its local transformation changes. godot.Spatial
will not propagate this by default.
@:native("IsScaleDisabled")isScaleDisabled():Bool
Returns whether this node uses a scale of (1, 1, 1)
or its local transformation scale.
@:native("IsSetAsToplevel")isSetAsToplevel():Bool
Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.
@:native("IsTransformNotificationEnabled")isTransformNotificationEnabled():Bool
Returns whether the node notifies about its global and local transformation changes. godot.Spatial
will not propagate this by default.
@:native("IsVisibleInTree")isVisibleInTree():Bool
Returns true
if the node is present in the godot.SceneTree
, its godot.Spatial.visible
property is true
and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.
@:native("LookAt")lookAt(target:Vector3, up:Vector3):Void
Rotates the node so that the local forward axis (-Z) points toward the target
position.
The local up axis (+Y) points as close to the up
vector as possible while staying perpendicular to the local forward axis. The resulting transform is orthogonal, and the scale is preserved. Non-uniform scaling may not work correctly.
The target
position cannot be the same as the node's position, the up
vector cannot be zero, and the direction from the node's position to the target
vector cannot be parallel to the up
vector.
Operations take place in global space.
@:native("LookAtFromPosition")lookAtFromPosition(position:Vector3, target:Vector3, up:Vector3):Void
Moves the node to the specified position
, and then rotates itself to point toward the target
as per godot.Spatial.lookAt
. Operations take place in global space.
@:native("Orthonormalize")orthonormalize():Void
Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's godot.Transform
.
@:native("Rotate")rotate(axis:Vector3, angle:Single):Void
Rotates the local transformation around axis, a unit godot.Vector3
, by specified angle in radians.
@:native("RotateObjectLocal")rotateObjectLocal(axis:Vector3, angle:Single):Void
Rotates the local transformation around axis, a unit godot.Vector3
, by specified angle in radians. The rotation axis is in object-local coordinate system.
@:native("RotateX")rotateX(angle:Single):Void
Rotates the local transformation around the X axis by angle in radians.
@:native("RotateY")rotateY(angle:Single):Void
Rotates the local transformation around the Y axis by angle in radians.
@:native("RotateZ")rotateZ(angle:Single):Void
Rotates the local transformation around the Z axis by angle in radians.
@:native("ScaleObjectLocal")scaleObjectLocal(scale:Vector3):Void
Scales the local transformation by given 3D scale factors in object-local coordinate system.
@:native("SetAsToplevel")setAsToplevel(enable:Bool):Void
Makes the node ignore its parents transformations. Node transformations are only in global space.
@:native("SetDisableScale")setDisableScale(disable:Bool):Void
Sets whether the node uses a scale of (1, 1, 1)
or its local transformation scale. Changes to the local transformation scale are preserved.
@:native("SetIdentity")setIdentity():Void
Reset all transformations for this node (sets its godot.Transform
to the identity matrix).
@:native("SetIgnoreTransformNotification")setIgnoreTransformNotification(enabled:Bool):Void
Sets whether the node ignores notification that its transformation (global or local) changed.
@:native("SetNotifyLocalTransform")setNotifyLocalTransform(enable:Bool):Void
Sets whether the node notifies about its local transformation changes. godot.Spatial
will not propagate this by default.
@:native("SetNotifyTransform")setNotifyTransform(enable:Bool):Void
Sets whether the node notifies about its global and local transformation changes. godot.Spatial
will not propagate this by default, unless it is in the editor context and it has a valid gizmo.
@:native("ToGlobal")toGlobal(localPoint:Vector3):Vector3
Transforms local_point
from this node's local space to world space.
@:native("ToLocal")toLocal(globalPoint:Vector3):Vector3
Transforms global_point
from world space to this node's local space.
@:native("Translate")translate(offset:Vector3):Void
Changes the node's position by the given offset godot.Vector3
.
Note that the translation offset
is affected by the node's scale, so if scaled by e.g. (10, 1, 1)
, a translation by an offset of (2, 0, 0)
would actually add 20 (2 * 10
) to the X coordinate.
@:native("TranslateObjectLocal")translateObjectLocal(offset:Vector3):Void
Changes the node's position by the given offset godot.Vector3
in local space.
Defined by Node
@:native("_EnterTree")_EnterTree():Void
Called when the node enters the godot.SceneTree
(e.g. upon instancing, scene changing, or after calling godot.Node.addChild
in a script). If the node has children, its godot.Node._EnterTree
callback will be called first, and then that of the children.
Corresponds to the godot.Node.notificationEnterTree
notification in godot.Object._Notification
.
@:native("_ExitTree")_ExitTree():Void
Called when the node is about to leave the godot.SceneTree
(e.g. upon freeing, scene changing, or after calling godot.Node.removeChild
in a script). If the node has children, its godot.Node._ExitTree
callback will be called last, after all its children have left the tree.
Corresponds to the godot.Node.notificationExitTree
notification in godot.Object._Notification
and signal tree_exiting
. To get notified when the node has already left the active tree, connect to the tree_exited
.
@:native("_GetConfigurationWarning")_GetConfigurationWarning():String
The string returned from this method is displayed as a warning in the Scene Dock if the script that overrides it is a tool
script.
Returning an empty string produces no warning.
Call godot.Node.updateConfigurationWarning
when the warning needs to be updated for this node.
@:native("_Input")_Input(event:InputEvent):Void
Called when there is an input event. The input event propagates up through the node tree until a node consumes it.
It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessInput
.
To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled
can be called.
For gameplay input, godot.Node._UnhandledInput
and godot.Node._UnhandledKeyInput
are usually a better fit as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_PhysicsProcess")_PhysicsProcess(delta:Single):Void
Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the delta
variable should be constant. delta
is in seconds.
It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setPhysicsProcess
.
Corresponds to the godot.Node.notificationPhysicsProcess
notification in godot.Object._Notification
.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_Process")_Process(delta:Single):Void
Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the delta
time since the previous frame is not constant. delta
is in seconds.
It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcess
.
Corresponds to the godot.Node.notificationProcess
notification in godot.Object._Notification
.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_Ready")_Ready():Void
Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their godot.Node._Ready
callbacks get triggered first, and the parent node will receive the ready notification afterwards.
Corresponds to the godot.Node.notificationReady
notification in godot.Object._Notification
. See also the onready
keyword for variables.
Usually used for initialization. For even earlier initialization, may be used. See also godot.Node._EnterTree
.
Note: godot.Node._Ready
may be called only once for each node. After removing a node from the scene tree and adding again, _ready
will not be called for the second time. This can be bypassed with requesting another call with godot.Node.requestReady
, which may be called anywhere before adding the node again.
@:native("_UnhandledInput")_UnhandledInput(event:InputEvent):Void
Called when an godot.InputEvent
hasn't been consumed by godot.Node._Input
or any GUI. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessUnhandledInput
.
To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled
can be called.
For gameplay input, this and godot.Node._UnhandledKeyInput
are usually a better fit than godot.Node._Input
as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_UnhandledKeyInput")_UnhandledKeyInput(event:InputEventKey):Void
Called when an godot.InputEventKey
hasn't been consumed by godot.Node._Input
or any GUI. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessUnhandledKeyInput
.
To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled
can be called.
For gameplay input, this and godot.Node._UnhandledInput
are usually a better fit than godot.Node._Input
as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("AddChild")addChild(node:Node, ?legibleUniqueName:Bool):Void
Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
If legible_unique_name
is true
, the child node will have a human-readable name based on the name of the node being instanced instead of its type.
Note: If the child node already has a parent, the function will fail. Use godot.Node.removeChild
first to remove the node from its current parent. For example:
if child_node.get_parent():
child_node.get_parent().remove_child(child_node)
add_child(child_node)
Note: If you want a child to be persisted to a godot.PackedScene
, you must set godot.Node.owner
in addition to calling godot.Node.addChild
. This is typically relevant for [https://docs.godotengine.org/en/3.4/tutorials/misc/running_code_in_the_editor.html](tool scripts) and [https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/index.html](editor plugins). If godot.Node.addChild
is called without setting godot.Node.owner
, the newly added godot.Node
will not be visible in the scene tree, though it will be visible in the 2D/3D view.
@:native("AddChildBelowNode")addChildBelowNode(node:Node, childNode:Node, ?legibleUniqueName:Bool):Void
Adds child_node
as a child. The child is placed below the given node
in the list of children.
If legible_unique_name
is true
, the child node will have a human-readable name based on the name of the node being instanced instead of its type.
@:native("AddToGroup")addToGroup(group:String, ?persistent:Bool):Void
Adds the node to a group. Groups are helpers to name and organize a subset of nodes, for example "enemies" or "collectables". A node can be in any number of groups. Nodes can be assigned a group at any time, but will not be added until they are inside the scene tree (see godot.Node.isInsideTree
). See notes in the description, and the group methods in godot.SceneTree
.
The persistent
option is used when packing node to godot.PackedScene
and saving to file. Non-persistent groups aren't stored.
Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
@:native("CanProcess")canProcess():Bool
Returns true
if the node can process while the scene tree is paused (see godot.Node.pauseMode
). Always returns true
if the scene tree is not paused, and false
if the node is not in the tree.
@:native("Duplicate")duplicate(?flags:Int):Node
Duplicates the node, returning a new node.
You can fine-tune the behavior using the flags
(see godot.Node_DuplicateFlags
).
Note: It will not work properly if the node contains a script with constructor arguments (i.e. needs to supply arguments to method). In that case, the node will be duplicated without a script.
@:native("FindNode")findNode(mask:String, ?recursive:Bool, ?owned:Bool):Node
Finds a descendant of this node whose name matches mask
as in String.match
(i.e. case-sensitive, but "*"
matches zero or more characters and "?"
matches any single character except "."
). Returns null
if no matching godot.Node
is found.
Note: It does not match against the full path, just against individual node names.
If owned
is true
, this method only finds nodes whose owner is this node. This is especially important for scenes instantiated through a script, because those scenes don't have an owner.
Note: As this method walks through all the descendants of the node, it is the slowest way to get a reference to another node. Whenever possible, consider using godot.Node.getNode
instead. To avoid using godot.Node.findNode
too often, consider caching the node reference into a variable.
@:native("FindParent")findParent(mask:String):Node
Finds the first parent of the current node whose name matches mask
as in String.match
(i.e. case-sensitive, but "*"
matches zero or more characters and "?"
matches any single character except "."
).
Note: It does not match against the full path, just against individual node names.
Note: As this method walks upwards in the scene tree, it can be slow in large, deeply nested scene trees. Whenever possible, consider using godot.Node.getNode
instead. To avoid using godot.Node.findParent
too often, consider caching the node reference into a variable.
@:native("GetChild")getChild(idx:Int):Node
Returns a child node by its index (see godot.Node.getChildCount
). This method is often used for iterating all children of a node.
To access a child node via its name, use godot.Node.getNode
.
@:native("GetGroups")getGroups():Array
Returns an array listing the groups that the node is a member of.
Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
Note: The engine uses some group names internally (all starting with an underscore). To avoid conflicts with internal groups, do not add custom groups whose name starts with an underscore. To exclude internal groups while looping over godot.Node.getGroups
, use the following snippet:
# Stores the node's non-internal groups only (as an array of Strings).
var non_internal_groups = []
for group in get_groups():
if not group.begins_with("_"):
non_internal_groups.push_back(group)
@:native("GetIndex")getIndex():Int
Returns the node's index, i.e. its position among the siblings of its parent.
@:native("GetNetworkMaster")getNetworkMaster():Int
Returns the peer ID of the network master for this node. See godot.Node.setNetworkMaster
.
@:native("GetNode")getNode(path:NodePath):Node
Fetches a node. The godot.NodePath
can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a null instance
is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error.
Note: Fetching absolute paths only works when the node is inside the scene tree (see godot.Node.isInsideTree
).
Example: Assume your current node is Character and the following tree:
/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin
Possible paths are:
get_node("Sword")
get_node("Backpack/Dagger")
get_node("../Swamp/Alligator")
get_node("/root/MyGame")
@:native("GetNodeAndResource")getNodeAndResource(path:NodePath):Array
Fetches a node and one of its resources as specified by the godot.NodePath
's subname (e.g. Area2D/CollisionShape2D:shape
). If several nested resources are specified in the godot.NodePath
, the last one will be fetched.
The return value is an array of size 3: the first index points to the godot.Node
(or null
if not found), the second index points to the godot.Resource
(or null
if not found), and the third index is the remaining godot.NodePath
, if any.
For example, assuming that Area2D/CollisionShape2D
is a valid node and that its shape
property has been assigned a godot.RectangleShape2D
resource, one could have this kind of output:
print(get_node_and_resource("Area2D/CollisionShape2D")) # [[CollisionShape2D:1161], Null, ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], :extents]
@:native("GetNodeOrNull")getNodeOrNull(path:NodePath):Node
Similar to godot.Node.getNode
, but does not log an error if path
does not point to a valid godot.Node
.
@:native("GetParent")getParent():Node
Returns the parent node of the current node, or a null instance
if the node lacks a parent.
@:native("GetPath")getPath():NodePath
Returns the absolute path of the current node. This only works if the current node is inside the scene tree (see godot.Node.isInsideTree
).
@:native("GetPathTo")getPathTo(node:Node):NodePath
Returns the relative godot.NodePath
from this node to the specified node
. Both nodes must be in the same scene or the function will fail.
@:native("GetPhysicsProcessDeltaTime")getPhysicsProcessDeltaTime():Single
Returns the time elapsed (in seconds) since the last physics-bound frame (see godot.Node._PhysicsProcess
). This is always a constant value in physics processing unless the frames per second is changed via godot.Engine.iterationsPerSecond
.
@:native("GetPositionInParent")getPositionInParent():Int
Returns the node's order in the scene tree branch. For example, if called on the first child node the position is 0
.
@:native("GetProcessDeltaTime")getProcessDeltaTime():Single
Returns the time elapsed (in seconds) since the last process callback. This value may vary from frame to frame.
@:native("GetSceneInstanceLoadPlaceholder")getSceneInstanceLoadPlaceholder():Bool
Returns true
if this is an instance load placeholder. See godot.InstancePlaceholder
.
@:native("HasNode")hasNode(path:NodePath):Bool
Returns true
if the node that the godot.NodePath
points to exists.
@:native("HasNodeAndResource")hasNodeAndResource(path:NodePath):Bool
Returns true
if the godot.NodePath
points to a valid node and its subname points to a valid resource, e.g. Area2D/CollisionShape2D:shape
. Properties with a non-godot.Resource
type (e.g. nodes or primitive math types) are not considered resources.
@:native("IsAParentOf")isAParentOf(node:Node):Bool
Returns true
if the given node is a direct or indirect child of the current node.
@:native("IsDisplayedFolded")isDisplayedFolded():Bool
Returns true
if the node is folded (collapsed) in the Scene dock.
@:native("IsGreaterThan")isGreaterThan(node:Node):Bool
Returns true
if the given node occurs later in the scene hierarchy than the current node.
@:native("IsInGroup")isInGroup(group:String):Bool
Returns true
if this node is in the specified group. See notes in the description, and the group methods in godot.SceneTree
.
@:native("IsInsideTree")isInsideTree():Bool
Returns true
if this node is currently inside a godot.SceneTree
.
@:native("IsNetworkMaster")isNetworkMaster():Bool
Returns true
if the local system is the master of this node.
@:native("IsPhysicsProcessing")isPhysicsProcessing():Bool
Returns true
if physics processing is enabled (see godot.Node.setPhysicsProcess
).
@:native("IsPhysicsProcessingInternal")isPhysicsProcessingInternal():Bool
Returns true
if internal physics processing is enabled (see godot.Node.setPhysicsProcessInternal
).
@:native("IsProcessing")isProcessing():Bool
Returns true
if processing is enabled (see godot.Node.setProcess
).
@:native("IsProcessingInput")isProcessingInput():Bool
Returns true
if the node is processing input (see godot.Node.setProcessInput
).
@:native("IsProcessingInternal")isProcessingInternal():Bool
Returns true
if internal processing is enabled (see godot.Node.setProcessInternal
).
@:native("IsProcessingUnhandledInput")isProcessingUnhandledInput():Bool
Returns true
if the node is processing unhandled input (see godot.Node.setProcessUnhandledInput
).
@:native("IsProcessingUnhandledKeyInput")isProcessingUnhandledKeyInput():Bool
Returns true
if the node is processing unhandled key input (see godot.Node.setProcessUnhandledKeyInput
).
@:native("MoveChild")moveChild(childNode:Node, toPosition:Int):Void
Moves a child node to a different position (order) among the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful.
@:native("PrintStrayNodes")printStrayNodes():Void
Prints all stray nodes (nodes outside the godot.SceneTree
). Used for debugging. Works only in debug builds.
@:native("PrintTree")printTree():Void
Prints the tree to stdout. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the godot.Node.getNode
function.
Example output:
TheGame
TheGame/Menu
TheGame/Menu/Label
TheGame/Menu/Camera2D
TheGame/SplashScreen
TheGame/SplashScreen/Camera2D
@:native("PrintTreePretty")printTreePretty():Void
Similar to godot.Node.printTree
, this prints the tree to stdout. This version displays a more graphical representation similar to what is displayed in the scene inspector. It is useful for inspecting larger trees.
Example output:
┖╴TheGame
┠╴Menu
┃ ┠╴Label
┃ ┖╴Camera2D
┖╴SplashScreen
┖╴Camera2D
@:native("PropagateCall")propagateCall(method:String, ?args:Array, ?parentFirst:Bool):Void
Calls the given method (if present) with the arguments given in args
on this node and recursively on all its children. If the parent_first
argument is true
, the method will be called on the current node first, then on all its children. If parent_first
is false
, the children will be called first.
Parameters:
args | If the parameter is null, then the default value is new Godot.Collections.Array { } |
---|
@:native("PropagateNotification")propagateNotification(what:Int):Void
Notifies the current node and all its children recursively by calling godot.Object.notification
on all of them.
@:native("QueueFree")queueFree():Void
Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to godot.Object.free
. Use godot.Object.isQueuedForDeletion
to check whether a node will be deleted at the end of the frame.
Important: If you have a variable pointing to a node, it will not be assigned to null
once the node 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("Raise")raise():Void
Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs (godot.Control
nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using raise
, a Control will be drawn on top of its siblings.
@:native("RemoveAndSkip")removeAndSkip():Void
Removes a node and sets all its children as children of the parent node (if it exists). All event subscriptions that pass by the removed node will be unsubscribed.
@:native("RemoveChild")removeChild(node:Node):Void
Removes a child node. The node is NOT deleted and must be deleted manually.
Note: This function may set the godot.Node.owner
of the removed Node (or its descendants) to be null
, if that godot.Node.owner
is no longer a parent or ancestor.
@:native("RemoveFromGroup")removeFromGroup(group:String):Void
Removes a node from a group. See notes in the description, and the group methods in godot.SceneTree
.
@:native("ReplaceBy")replaceBy(node:Node, ?keepData:Bool):Void
Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost.
Note that the replaced node is not automatically freed, so you either need to keep it in a variable for later use or free it using godot.Object.free
.
@:native("RequestReady")requestReady():Void
Requests that _ready
be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see godot.Node._Ready
). _ready
is called only for the node which requested it, which means that you need to request ready for each child if you want them to call _ready
too (in which case, _ready
will be called in the same order as it would normally).
@:native("Rpc")rpc(method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a remote procedure call request for the given method
to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same godot.NodePath
, including the exact same node name. Behaviour depends on the RPC configuration for the given method, see godot.Node.rpcConfig
. Methods are not exposed to RPCs by default. See also godot.Node.rset
and godot.Node.rsetConfig
for properties. Returns null
.
Note: You can only safely use RPCs on clients after you received the connected_to_server
signal from the godot.SceneTree
. You also need to keep track of the connection state, either by the godot.SceneTree
signals like server_disconnected
or by checking SceneTree.network_peer.get_connection_status() == CONNECTION_CONNECTED
.
@:native("RpcConfig")rpcConfig(method:String, mode:MultiplayerAPI_RPCMode):Void
Changes the RPC mode for the given method
to the given mode
. See godot.MultiplayerAPI_RPCMode
. An alternative is annotating methods and properties with the corresponding keywords (remote
, master
, puppet
, remotesync
, mastersync
, puppetsync
). By default, methods are not exposed to networking (and RPCs). See also godot.Node.rset
and godot.Node.rsetConfig
for properties.
@:native("RpcId")rpcId(peerId:Int, method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a godot.Node.rpc
to a specific peer identified by peer_id
(see godot.NetworkedMultiplayerPeer.setTargetPeer
). Returns null
.
@:native("RpcUnreliable")rpcUnreliable(method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a godot.Node.rpc
using an unreliable protocol. Returns null
.
@:native("RpcUnreliableId")rpcUnreliableId(peerId:Int, method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a godot.Node.rpc
to a specific peer identified by peer_id
using an unreliable protocol (see godot.NetworkedMultiplayerPeer.setTargetPeer
). Returns null
.
@:native("Rset")rset(property:String, value:Dynamic):Void
Remotely changes a property's value on other peers (and locally). Behaviour depends on the RPC configuration for the given property, see godot.Node.rsetConfig
. See also godot.Node.rpc
for RPCs for methods, most information applies to this method as well.
@:native("RsetConfig")rsetConfig(property:String, mode:MultiplayerAPI_RPCMode):Void
Changes the RPC mode for the given property
to the given mode
. See godot.MultiplayerAPI_RPCMode
. An alternative is annotating methods and properties with the corresponding keywords (remote
, master
, puppet
, remotesync
, mastersync
, puppetsync
). By default, properties are not exposed to networking (and RPCs). See also godot.Node.rpc
and godot.Node.rpcConfig
for methods.
@:native("RsetId")rsetId(peerId:Int, property:String, value:Dynamic):Void
Remotely changes the property's value on a specific peer identified by peer_id
(see godot.NetworkedMultiplayerPeer.setTargetPeer
).
@:native("RsetUnreliable")rsetUnreliable(property:String, value:Dynamic):Void
Remotely changes the property's value on other peers (and locally) using an unreliable protocol.
@:native("RsetUnreliableId")rsetUnreliableId(peerId:Int, property:String, value:Dynamic):Void
Remotely changes property's value on a specific peer identified by peer_id
using an unreliable protocol (see godot.NetworkedMultiplayerPeer.setTargetPeer
).
@:native("SetDisplayFolded")setDisplayFolded(fold:Bool):Void
Sets the folded state of the node in the Scene dock.
@:native("SetNetworkMaster")setNetworkMaster(id:Int, ?recursive:Bool):Void
Sets the node's network master to the peer with the given peer ID. The network master is the peer that has authority over the node on the network. Useful in conjunction with the master
and puppet
keywords. Inherited from the parent node by default, which ultimately defaults to peer ID 1 (the server). If recursive
, the given peer is recursively set as the master for all children of this node.
@:native("SetPhysicsProcess")setPhysicsProcess(enable:Bool):Void
Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a godot.Node.notificationPhysicsProcess
at a fixed (usually 60 FPS, see godot.Engine.iterationsPerSecond
to change) interval (and the godot.Node._PhysicsProcess
callback will be called if exists). Enabled automatically if godot.Node._PhysicsProcess
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetPhysicsProcessInternal")setPhysicsProcessInternal(enable:Bool):Void
Enables or disables internal physics for this node. Internal physics processing happens in isolation from the normal godot.Node._PhysicsProcess
calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting (godot.Node.setPhysicsProcess
). Only useful for advanced uses to manipulate built-in nodes' behavior.
Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.
@:native("SetProcess")setProcess(enable:Bool):Void
Enables or disables processing. When a node is being processed, it will receive a godot.Node.notificationProcess
on every drawn frame (and the godot.Node._Process
callback will be called if exists). Enabled automatically if godot.Node._Process
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetProcessInput")setProcessInput(enable:Bool):Void
Enables or disables input processing. This is not required for GUI controls! Enabled automatically if godot.Node._Input
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetProcessInternal")setProcessInternal(enable:Bool):Void
Enables or disabled internal processing for this node. Internal processing happens in isolation from the normal godot.Node._Process
calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting (godot.Node.setProcess
). Only useful for advanced uses to manipulate built-in nodes' behavior.
Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.
@:native("SetProcessUnhandledInput")setProcessUnhandledInput(enable:Bool):Void
Enables unhandled input processing. This is not required for GUI controls! It enables the node to receive all input that was not previously handled (usually by a godot.Control
). Enabled automatically if godot.Node._UnhandledInput
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetProcessUnhandledKeyInput")setProcessUnhandledKeyInput(enable:Bool):Void
Enables unhandled key input processing. Enabled automatically if godot.Node._UnhandledKeyInput
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetSceneInstanceLoadPlaceholder")setSceneInstanceLoadPlaceholder(loadPlaceholder:Bool):Void
Sets whether this is an instance load placeholder. See godot.InstancePlaceholder
.
@:native("UpdateConfigurationWarning")updateConfigurationWarning():Void
Updates the warning displayed for this node in the Scene Dock.
Use godot.Node._GetConfigurationWarning
to setup the warning message to display.
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.Node
s, 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.Node
s 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
.
@: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("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.
|
Returns:
A godot.SignalAwaiter
that completes when
source
emits the signal
.
@:native("ToString")toString():String
@: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
.