// AUTO-GENERATED
///
declare module "godot" {
// _singleton_class_: PhysicsServer2D
namespace PhysicsServer2D {
enum SpaceParameter {
/** Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated. The default value of this parameter is [member ProjectSettings.physics/2d/solver/contact_recycle_radius]. */
SPACE_PARAM_CONTACT_RECYCLE_RADIUS = 0,
/** Constant to set/get the maximum distance a shape can be from another before they are considered separated and the contact is discarded. The default value of this parameter is [member ProjectSettings.physics/2d/solver/contact_max_separation]. */
SPACE_PARAM_CONTACT_MAX_SEPARATION = 1,
/** Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision. The default value of this parameter is [member ProjectSettings.physics/2d/solver/contact_max_allowed_penetration]. */
SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION = 2,
/** Constant to set/get the default solver bias for all physics contacts. A solver bias is a factor controlling how much two objects "rebound", after overlapping, to avoid leaving them in that state because of numerical imprecision. The default value of this parameter is [member ProjectSettings.physics/2d/solver/default_contact_bias]. */
SPACE_PARAM_CONTACT_DEFAULT_BIAS = 3,
/** Constant to set/get the threshold linear velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given. The default value of this parameter is [member ProjectSettings.physics/2d/sleep_threshold_linear]. */
SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD = 4,
/** Constant to set/get the threshold angular velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given. The default value of this parameter is [member ProjectSettings.physics/2d/sleep_threshold_angular]. */
SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD = 5,
/** Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time. The default value of this parameter is [member ProjectSettings.physics/2d/time_before_sleep]. */
SPACE_PARAM_BODY_TIME_TO_SLEEP = 6,
/** Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision. The default value of this parameter is [member ProjectSettings.physics/2d/solver/default_constraint_bias]. */
SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS = 7,
/** Constant to set/get the number of solver iterations for all contacts and constraints. The greater the number of iterations, the more accurate the collisions will be. However, a greater number of iterations requires more CPU power, which can decrease performance. The default value of this parameter is [member ProjectSettings.physics/2d/solver/solver_iterations]. */
SPACE_PARAM_SOLVER_ITERATIONS = 8,
}
enum ShapeType {
/** This is the constant for creating world boundary shapes. A world boundary shape is an *infinite* line with an origin point, and a normal. Thus, it can be used for front/behind checks. */
SHAPE_WORLD_BOUNDARY = 0,
/** This is the constant for creating separation ray shapes. A separation ray is defined by a length and separates itself from what is touching its far endpoint. Useful for character controllers. */
SHAPE_SEPARATION_RAY = 1,
/** This is the constant for creating segment shapes. A segment shape is a *finite* line from a point A to a point B. It can be checked for intersections. */
SHAPE_SEGMENT = 2,
/** This is the constant for creating circle shapes. A circle shape only has a radius. It can be used for intersections and inside/outside checks. */
SHAPE_CIRCLE = 3,
/** This is the constant for creating rectangle shapes. A rectangle shape is defined by a width and a height. It can be used for intersections and inside/outside checks. */
SHAPE_RECTANGLE = 4,
/** This is the constant for creating capsule shapes. A capsule shape is defined by a radius and a length. It can be used for intersections and inside/outside checks. */
SHAPE_CAPSULE = 5,
/** This is the constant for creating convex polygon shapes. A polygon is defined by a list of points. It can be used for intersections and inside/outside checks. */
SHAPE_CONVEX_POLYGON = 6,
/** This is the constant for creating concave polygon shapes. A polygon is defined by a list of points. It can be used for intersections checks, but not for inside/outside checks. */
SHAPE_CONCAVE_POLYGON = 7,
/** This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. */
SHAPE_CUSTOM = 8,
}
enum AreaParameter {
/** Constant to set/get gravity override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. The default value of this parameter is [constant AREA_SPACE_OVERRIDE_DISABLED]. */
AREA_PARAM_GRAVITY_OVERRIDE_MODE = 0,
/** Constant to set/get gravity strength in an area. The default value of this parameter is `9.80665`. */
AREA_PARAM_GRAVITY = 1,
/** Constant to set/get gravity vector/center in an area. The default value of this parameter is `Vector2(0, -1)`. */
AREA_PARAM_GRAVITY_VECTOR = 2,
/** Constant to set/get whether the gravity vector of an area is a direction, or a center point. The default value of this parameter is `false`. */
AREA_PARAM_GRAVITY_IS_POINT = 3,
/** Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by [constant AREA_PARAM_GRAVITY]. For example, on a planet 100 pixels in radius with a surface gravity of 4.0 px/s², set the gravity to 4.0 and the unit distance to 100.0. The gravity will have falloff according to the inverse square law, so in the example, at 200 pixels from the center the gravity will be 1.0 px/s² (twice the distance, 1/4th the gravity), at 50 pixels it will be 16.0 px/s² (half the distance, 4x the gravity), and so on.
* The above is true only when the unit distance is a positive number. When the unit distance is set to 0.0, the gravity will be constant regardless of distance. The default value of this parameter is `0.0`.
*/
AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE = 4,
/** Constant to set/get linear damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. The default value of this parameter is [constant AREA_SPACE_OVERRIDE_DISABLED]. */
AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE = 5,
/** Constant to set/get the linear damping factor of an area. The default value of this parameter is `0.1`. */
AREA_PARAM_LINEAR_DAMP = 6,
/** Constant to set/get angular damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. The default value of this parameter is [constant AREA_SPACE_OVERRIDE_DISABLED]. */
AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE = 7,
/** Constant to set/get the angular damping factor of an area. The default value of this parameter is `1.0`. */
AREA_PARAM_ANGULAR_DAMP = 8,
/** Constant to set/get the priority (order of processing) of an area. The default value of this parameter is `0`. */
AREA_PARAM_PRIORITY = 9,
}
enum AreaSpaceOverrideMode {
/** This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them. */
AREA_SPACE_OVERRIDE_DISABLED = 0,
/** This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects. */
AREA_SPACE_OVERRIDE_COMBINE = 1,
/** This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one. */
AREA_SPACE_OVERRIDE_COMBINE_REPLACE = 2,
/** This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas. */
AREA_SPACE_OVERRIDE_REPLACE = 3,
/** This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one. */
AREA_SPACE_OVERRIDE_REPLACE_COMBINE = 4,
}
enum BodyMode {
/** Constant for static bodies. In this mode, a body can be only moved by user code and doesn't collide with other bodies along its path when moved. */
BODY_MODE_STATIC = 0,
/** Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path. */
BODY_MODE_KINEMATIC = 1,
/** Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied. */
BODY_MODE_RIGID = 2,
/** Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces. */
BODY_MODE_RIGID_LINEAR = 3,
}
enum BodyParameter {
/** Constant to set/get a body's bounce factor. The default value of this parameter is `0.0`. */
BODY_PARAM_BOUNCE = 0,
/** Constant to set/get a body's friction. The default value of this parameter is `1.0`. */
BODY_PARAM_FRICTION = 1,
/** Constant to set/get a body's mass. The default value of this parameter is `1.0`. If the body's mode is set to [constant BODY_MODE_RIGID], then setting this parameter will have the following additional effects:
* - If the parameter [constant BODY_PARAM_CENTER_OF_MASS] has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.
* - If the parameter [constant BODY_PARAM_INERTIA] is set to a value `<= 0.0`, then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass.
*/
BODY_PARAM_MASS = 2,
/** Constant to set/get a body's inertia. The default value of this parameter is `0.0`. If the body's inertia is set to a value `<= 0.0`, then the inertia will be recalculated based on the body's shapes, mass, and center of mass. */
BODY_PARAM_INERTIA = 3,
/** Constant to set/get a body's center of mass position in the body's local coordinate system. The default value of this parameter is `Vector2(0,0)`. If this parameter is never set explicitly, then it is recalculated based on the body's shapes when setting the parameter [constant BODY_PARAM_MASS] or when calling [method body_set_space]. */
BODY_PARAM_CENTER_OF_MASS = 4,
/** Constant to set/get a body's gravity multiplier. The default value of this parameter is `1.0`. */
BODY_PARAM_GRAVITY_SCALE = 5,
/** Constant to set/get a body's linear damping mode. See [enum BodyDampMode] for possible values. The default value of this parameter is [constant BODY_DAMP_MODE_COMBINE]. */
BODY_PARAM_LINEAR_DAMP_MODE = 6,
/** Constant to set/get a body's angular damping mode. See [enum BodyDampMode] for possible values. The default value of this parameter is [constant BODY_DAMP_MODE_COMBINE]. */
BODY_PARAM_ANGULAR_DAMP_MODE = 7,
/** Constant to set/get a body's linear damping factor. The default value of this parameter is `0.0`. */
BODY_PARAM_LINEAR_DAMP = 8,
/** Constant to set/get a body's angular damping factor. The default value of this parameter is `0.0`. */
BODY_PARAM_ANGULAR_DAMP = 9,
/** Represents the size of the [enum BodyParameter] enum. */
BODY_PARAM_MAX = 10,
}
enum BodyDampMode {
/** The body's damping value is added to any value set in areas or the default value. */
BODY_DAMP_MODE_COMBINE = 0,
/** The body's damping value replaces any value set in areas or the default value. */
BODY_DAMP_MODE_REPLACE = 1,
}
enum BodyState {
/** Constant to set/get the current transform matrix of the body. */
BODY_STATE_TRANSFORM = 0,
/** Constant to set/get the current linear velocity of the body. */
BODY_STATE_LINEAR_VELOCITY = 1,
/** Constant to set/get the current angular velocity of the body. */
BODY_STATE_ANGULAR_VELOCITY = 2,
/** Constant to sleep/wake up a body, or to get whether it is sleeping. */
BODY_STATE_SLEEPING = 3,
/** Constant to set/get whether the body can sleep. */
BODY_STATE_CAN_SLEEP = 4,
}
enum JointType {
/** Constant to create pin joints. */
JOINT_TYPE_PIN = 0,
/** Constant to create groove joints. */
JOINT_TYPE_GROOVE = 1,
/** Constant to create damped spring joints. */
JOINT_TYPE_DAMPED_SPRING = 2,
/** Represents the size of the [enum JointType] enum. */
JOINT_TYPE_MAX = 3,
}
enum JointParam {
/** Constant to set/get how fast the joint pulls the bodies back to satisfy the joint constraint. The lower the value, the more the two bodies can pull on the joint. The default value of this parameter is `0.0`.
*
* **Note:** In Godot Physics, this parameter is only used for pin joints and groove joints.
*/
JOINT_PARAM_BIAS = 0,
/** Constant to set/get the maximum speed with which the joint can apply corrections. The default value of this parameter is `3.40282e+38`.
*
* **Note:** In Godot Physics, this parameter is only used for groove joints.
*/
JOINT_PARAM_MAX_BIAS = 1,
/** Constant to set/get the maximum force that the joint can use to act on the two bodies. The default value of this parameter is `3.40282e+38`.
*
* **Note:** In Godot Physics, this parameter is only used for groove joints.
*/
JOINT_PARAM_MAX_FORCE = 2,
}
enum PinJointParam {
/** Constant to set/get a how much the bond of the pin joint can flex. The default value of this parameter is `0.0`. */
PIN_JOINT_SOFTNESS = 0,
/** The maximum rotation around the pin. */
PIN_JOINT_LIMIT_UPPER = 1,
/** The minimum rotation around the pin. */
PIN_JOINT_LIMIT_LOWER = 2,
/** Target speed for the motor. In radians per second. */
PIN_JOINT_MOTOR_TARGET_VELOCITY = 3,
}
enum PinJointFlag {
/** If `true`, the pin has a maximum and a minimum rotation. */
PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED = 0,
/** If `true`, a motor turns the pin. */
PIN_JOINT_FLAG_MOTOR_ENABLED = 1,
}
enum DampedSpringParam {
/** Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart. The default value of this parameter is the distance between the joint's anchor points. */
DAMPED_SPRING_REST_LENGTH = 0,
/** Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length. The default value of this parameter is `20.0`. */
DAMPED_SPRING_STIFFNESS = 1,
/** Sets the damping ratio of the spring joint. A value of 0 indicates an undamped spring, while 1 causes the system to reach equilibrium as fast as possible (critical damping). The default value of this parameter is `1.5`. */
DAMPED_SPRING_DAMPING = 2,
}
enum CCDMode {
/** Disables continuous collision detection. This is the fastest way to detect body collisions, but it can miss small and/or fast-moving objects. */
CCD_MODE_DISABLED = 0,
/** Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise. */
CCD_MODE_CAST_RAY = 1,
/** Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise. */
CCD_MODE_CAST_SHAPE = 2,
}
enum AreaBodyStatus {
/** The value of the first parameter and area callback function receives, when an object enters one of its shapes. */
AREA_BODY_ADDED = 0,
/** The value of the first parameter and area callback function receives, when an object exits one of its shapes. */
AREA_BODY_REMOVED = 1,
}
enum ProcessInfo {
/** Constant to get the number of objects that are not sleeping. */
INFO_ACTIVE_OBJECTS = 0,
/** Constant to get the number of possible collisions. */
INFO_COLLISION_PAIRS = 1,
/** Constant to get the number of space regions where a collision could occur. */
INFO_ISLAND_COUNT = 2,
}
}
/** A server interface for low-level 2D physics access.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_physicsserver2d.html
*/
class PhysicsServer2D extends Object {
/** Creates a 2D world boundary shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the shape's normal direction and distance properties. */
static world_boundary_shape_create(): RID
/** Creates a 2D separation ray shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the shape's `length` and `slide_on_slope` properties. */
static separation_ray_shape_create(): RID
/** Creates a 2D segment shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the segment's start and end points. */
static segment_shape_create(): RID
/** Creates a 2D circle shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the circle's radius. */
static circle_shape_create(): RID
/** Creates a 2D rectangle shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the rectangle's half-extents. */
static rectangle_shape_create(): RID
/** Creates a 2D capsule shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the capsule's height and radius. */
static capsule_shape_create(): RID
/** Creates a 2D convex polygon shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the convex polygon's points. */
static convex_polygon_shape_create(): RID
/** Creates a 2D concave polygon shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the concave polygon's segments. */
static concave_polygon_shape_create(): RID
/** Sets the shape data that defines the configuration of the shape. The [param data] to be passed depends on the shape's type (see [method shape_get_type]):
* - [constant SHAPE_WORLD_BOUNDARY]: an array of length two containing a [Vector2] `normal` direction and a [float] distance `d`,
* - [constant SHAPE_SEPARATION_RAY]: a dictionary containing the key `length` with a [float] value and the key `slide_on_slope` with a [bool] value,
* - [constant SHAPE_SEGMENT]: a [Rect2] `rect` containing the first point of the segment in `rect.position` and the second point of the segment in `rect.size`,
* - [constant SHAPE_CIRCLE]: a [float] `radius`,
* - [constant SHAPE_RECTANGLE]: a [Vector2] `half_extents`,
* - [constant SHAPE_CAPSULE]: an array of length two (or a [Vector2]) containing a [float] `height` and a [float] `radius`,
* - [constant SHAPE_CONVEX_POLYGON]: either a [PackedVector2Array] of points defining a convex polygon in counterclockwise order (the clockwise outward normal of each segment formed by consecutive points is calculated internally), or a [PackedFloat32Array] of length divisible by four so that every 4-tuple of [float]s contains the coordinates of a point followed by the coordinates of the clockwise outward normal vector to the segment between the current point and the next point,
* - [constant SHAPE_CONCAVE_POLYGON]: a [PackedVector2Array] of length divisible by two (each pair of points forms one segment).
* **Warning:** In the case of [constant SHAPE_CONVEX_POLYGON], this method does not check if the points supplied actually form a convex polygon (unlike the [member CollisionPolygon2D.polygon] property).
*/
static shape_set_data(shape: RID, data: any): void
/** Returns the shape's type (see [enum ShapeType]). */
static shape_get_type(shape: RID): PhysicsServer2D.ShapeType
/** Returns the shape data that defines the configuration of the shape, such as the half-extents of a rectangle or the segments of a concave shape. See [method shape_set_data] for the precise format of this data in each case. */
static shape_get_data(shape: RID): any
/** Creates a 2D space in the physics server, and returns the [RID] that identifies it. A space contains bodies and areas, and controls the stepping of the physics simulation of the objects in it. */
static space_create(): RID
/** Activates or deactivates the space. If [param active] is `false`, then the physics server will not do anything with this space in its physics step. */
static space_set_active(space: RID, active: boolean): void
/** Returns `true` if the space is active. */
static space_is_active(space: RID): boolean
/** Sets the value of the given space parameter. See [enum SpaceParameter] for the list of available parameters. */
static space_set_param(space: RID, param: PhysicsServer2D.SpaceParameter, value: float64): void
/** Returns the value of the given space parameter. See [enum SpaceParameter] for the list of available parameters. */
static space_get_param(space: RID, param: PhysicsServer2D.SpaceParameter): float64
/** Returns the state of a space, a [PhysicsDirectSpaceState2D]. This object can be used for collision/intersection queries. */
static space_get_direct_state(space: RID): PhysicsDirectSpaceState2D
/** Creates a 2D area object in the physics server, and returns the [RID] that identifies it. The default settings for the created area include a collision layer and mask set to `1`, and `monitorable` set to `false`.
* Use [method area_add_shape] to add shapes to it, use [method area_set_transform] to set its transform, and use [method area_set_space] to add the area to a space. If you want the area to be detectable use [method area_set_monitorable].
*/
static area_create(): RID
/** Adds the area to the given space, after removing the area from the previously assigned space (if any).
*
* **Note:** To remove an area from a space without immediately adding it back elsewhere, use `PhysicsServer2D.area_set_space(area, RID())`.
*/
static area_set_space(area: RID, space: RID): void
/** Returns the [RID] of the space assigned to the area. Returns an empty [RID] if no space is assigned. */
static area_get_space(area: RID): RID
/** Adds a shape to the area, with the given local transform. The shape (together with its [param transform] and [param disabled] properties) is added to an array of shapes, and the shapes of an area are usually referenced by their index in this array. */
static area_add_shape(area: RID, shape: RID, transform: Transform2D = new Transform2D(), disabled: boolean = false): void
/** Replaces the area's shape at the given index by another shape, while not affecting the `transform` and `disabled` properties at the same index. */
static area_set_shape(area: RID, shape_idx: int64, shape: RID): void
/** Sets the local transform matrix of the area's shape with the given index. */
static area_set_shape_transform(area: RID, shape_idx: int64, transform: Transform2D): void
/** Sets the disabled property of the area's shape with the given index. If [param disabled] is `true`, then the shape will not detect any other shapes entering or exiting it. */
static area_set_shape_disabled(area: RID, shape_idx: int64, disabled: boolean): void
/** Returns the number of shapes added to the area. */
static area_get_shape_count(area: RID): int64
/** Returns the [RID] of the shape with the given index in the area's array of shapes. */
static area_get_shape(area: RID, shape_idx: int64): RID
/** Returns the local transform matrix of the shape with the given index in the area's array of shapes. */
static area_get_shape_transform(area: RID, shape_idx: int64): Transform2D
/** Removes the shape with the given index from the area's array of shapes. The shape itself is not deleted, so it can continue to be used elsewhere or added back later. As a result of this operation, the area's shapes which used to have indices higher than [param shape_idx] will have their index decreased by one. */
static area_remove_shape(area: RID, shape_idx: int64): void
/** Removes all shapes from the area. This does not delete the shapes themselves, so they can continue to be used elsewhere or added back later. */
static area_clear_shapes(area: RID): void
/** Assigns the area to one or many physics layers, via a bitmask. */
static area_set_collision_layer(area: RID, layer: int64): void
/** Returns the physics layer or layers the area belongs to, as a bitmask. */
static area_get_collision_layer(area: RID): int64
/** Sets which physics layers the area will monitor, via a bitmask. */
static area_set_collision_mask(area: RID, mask: int64): void
/** Returns the physics layer or layers the area can contact with, as a bitmask. */
static area_get_collision_mask(area: RID): int64
/** Sets the value of the given area parameter. See [enum AreaParameter] for the list of available parameters. */
static area_set_param(area: RID, param: PhysicsServer2D.AreaParameter, value: any): void
/** Sets the transform matrix of the area. */
static area_set_transform(area: RID, transform: Transform2D): void
/** Returns the value of the given area parameter. See [enum AreaParameter] for the list of available parameters. */
static area_get_param(area: RID, param: PhysicsServer2D.AreaParameter): any
/** Returns the transform matrix of the area. */
static area_get_transform(area: RID): Transform2D
/** Attaches the `ObjectID` of an [Object] to the area. Use [method Object.get_instance_id] to get the `ObjectID` of a [CollisionObject2D]. */
static area_attach_object_instance_id(area: RID, id: int64): void
/** Returns the `ObjectID` attached to the area. Use [method @GlobalScope.instance_from_id] to retrieve an [Object] from a nonzero `ObjectID`. */
static area_get_object_instance_id(area: RID): int64
/** Attaches the `ObjectID` of a canvas to the area. Use [method Object.get_instance_id] to get the `ObjectID` of a [CanvasLayer]. */
static area_attach_canvas_instance_id(area: RID, id: int64): void
/** Returns the `ObjectID` of the canvas attached to the area. Use [method @GlobalScope.instance_from_id] to retrieve a [CanvasLayer] from a nonzero `ObjectID`. */
static area_get_canvas_instance_id(area: RID): int64
/** Sets the area's body monitor callback. This callback will be called when any other (shape of a) body enters or exits (a shape of) the given area, and must take the following five parameters:
* 1. an integer `status`: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other body shape entered or exited the area,
* 2. an [RID] `body_rid`: the [RID] of the body that entered or exited the area,
* 3. an integer `instance_id`: the `ObjectID` attached to the body,
* 4. an integer `body_shape_idx`: the index of the shape of the body that entered or exited the area,
* 5. an integer `self_shape_idx`: the index of the shape of the area where the body entered or exited.
* By counting (or keeping track of) the shapes that enter and exit, it can be determined if a body (with all its shapes) is entering for the first time or exiting for the last time.
*/
static area_set_monitor_callback(area: RID, callback: Callable): void
/** Sets the area's area monitor callback. This callback will be called when any other (shape of an) area enters or exits (a shape of) the given area, and must take the following five parameters:
* 1. an integer `status`: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other area's shape entered or exited the area,
* 2. an [RID] `area_rid`: the [RID] of the other area that entered or exited the area,
* 3. an integer `instance_id`: the `ObjectID` attached to the other area,
* 4. an integer `area_shape_idx`: the index of the shape of the other area that entered or exited the area,
* 5. an integer `self_shape_idx`: the index of the shape of the area where the other area entered or exited.
* By counting (or keeping track of) the shapes that enter and exit, it can be determined if an area (with all its shapes) is entering for the first time or exiting for the last time.
*/
static area_set_area_monitor_callback(area: RID, callback: Callable): void
/** Sets whether the area is monitorable or not. If [param monitorable] is `true`, the area monitoring callback of other areas will be called when this area enters or exits them. */
static area_set_monitorable(area: RID, monitorable: boolean): void
/** Creates a 2D body object in the physics server, and returns the [RID] that identifies it. The default settings for the created area include a collision layer and mask set to `1`, and body mode set to [constant BODY_MODE_RIGID].
* Use [method body_add_shape] to add shapes to it, use [method body_set_state] to set its transform, and use [method body_set_space] to add the body to a space.
*/
static body_create(): RID
/** Adds the body to the given space, after removing the body from the previously assigned space (if any). If the body's mode is set to [constant BODY_MODE_RIGID], then adding the body to a space will have the following additional effects:
* - If the parameter [constant BODY_PARAM_CENTER_OF_MASS] has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.
* - If the parameter [constant BODY_PARAM_INERTIA] is set to a value `<= 0.0`, then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass.
*
* **Note:** To remove a body from a space without immediately adding it back elsewhere, use `PhysicsServer2D.body_set_space(body, RID())`.
*/
static body_set_space(body: RID, space: RID): void
/** Returns the [RID] of the space assigned to the body. Returns an empty [RID] if no space is assigned. */
static body_get_space(body: RID): RID
/** Sets the body's mode. See [enum BodyMode] for the list of available modes. */
static body_set_mode(body: RID, mode: PhysicsServer2D.BodyMode): void
/** Returns the body's mode (see [enum BodyMode]). */
static body_get_mode(body: RID): PhysicsServer2D.BodyMode
/** Adds a shape to the area, with the given local transform. The shape (together with its [param transform] and [param disabled] properties) is added to an array of shapes, and the shapes of a body are usually referenced by their index in this array. */
static body_add_shape(body: RID, shape: RID, transform: Transform2D = new Transform2D(), disabled: boolean = false): void
/** Replaces the body's shape at the given index by another shape, while not affecting the `transform`, `disabled`, and one-way collision properties at the same index. */
static body_set_shape(body: RID, shape_idx: int64, shape: RID): void
/** Sets the local transform matrix of the body's shape with the given index. */
static body_set_shape_transform(body: RID, shape_idx: int64, transform: Transform2D): void
/** Returns the number of shapes added to the body. */
static body_get_shape_count(body: RID): int64
/** Returns the [RID] of the shape with the given index in the body's array of shapes. */
static body_get_shape(body: RID, shape_idx: int64): RID
/** Returns the local transform matrix of the shape with the given index in the area's array of shapes. */
static body_get_shape_transform(body: RID, shape_idx: int64): Transform2D
/** Removes the shape with the given index from the body's array of shapes. The shape itself is not deleted, so it can continue to be used elsewhere or added back later. As a result of this operation, the body's shapes which used to have indices higher than [param shape_idx] will have their index decreased by one. */
static body_remove_shape(body: RID, shape_idx: int64): void
/** Removes all shapes from the body. This does not delete the shapes themselves, so they can continue to be used elsewhere or added back later. */
static body_clear_shapes(body: RID): void
/** Sets the disabled property of the body's shape with the given index. If [param disabled] is `true`, then the shape will be ignored in all collision detection. */
static body_set_shape_disabled(body: RID, shape_idx: int64, disabled: boolean): void
/** Sets the one-way collision properties of the body's shape with the given index. If [param enable] is `true`, the one-way collision direction given by the shape's local upward axis `body_get_shape_transform(body, shape_idx).y` will be used to ignore collisions with the shape in the opposite direction, and to ensure depenetration of kinematic bodies happens in this direction. */
static body_set_shape_as_one_way_collision(body: RID, shape_idx: int64, enable: boolean, margin: float64): void
/** Attaches the `ObjectID` of an [Object] to the body. Use [method Object.get_instance_id] to get the `ObjectID` of a [CollisionObject2D]. */
static body_attach_object_instance_id(body: RID, id: int64): void
/** Returns the `ObjectID` attached to the body. Use [method @GlobalScope.instance_from_id] to retrieve an [Object] from a nonzero `ObjectID`. */
static body_get_object_instance_id(body: RID): int64
/** Attaches the `ObjectID` of a canvas to the body. Use [method Object.get_instance_id] to get the `ObjectID` of a [CanvasLayer]. */
static body_attach_canvas_instance_id(body: RID, id: int64): void
/** Returns the `ObjectID` of the canvas attached to the body. Use [method @GlobalScope.instance_from_id] to retrieve a [CanvasLayer] from a nonzero `ObjectID`. */
static body_get_canvas_instance_id(body: RID): int64
/** Sets the continuous collision detection mode using one of the [enum CCDMode] constants.
* Continuous collision detection tries to predict where a moving body would collide in between physics updates, instead of moving it and correcting its movement if it collided.
*/
static body_set_continuous_collision_detection_mode(body: RID, mode: PhysicsServer2D.CCDMode): void
/** Returns the body's continuous collision detection mode (see [enum CCDMode]). */
static body_get_continuous_collision_detection_mode(body: RID): PhysicsServer2D.CCDMode
/** Sets the physics layer or layers the body belongs to, via a bitmask. */
static body_set_collision_layer(body: RID, layer: int64): void
/** Returns the physics layer or layers the body belongs to, as a bitmask. */
static body_get_collision_layer(body: RID): int64
/** Sets the physics layer or layers the body can collide with, via a bitmask. */
static body_set_collision_mask(body: RID, mask: int64): void
/** Returns the physics layer or layers the body can collide with, as a bitmask. */
static body_get_collision_mask(body: RID): int64
/** Sets the body's collision priority. This is used in the depenetration phase of [method body_test_motion]. The higher the priority is, the lower the penetration into the body will be. */
static body_set_collision_priority(body: RID, priority: float64): void
/** Returns the body's collision priority. This is used in the depenetration phase of [method body_test_motion]. The higher the priority is, the lower the penetration into the body will be. */
static body_get_collision_priority(body: RID): float64
/** Sets the value of the given body parameter. See [enum BodyParameter] for the list of available parameters. */
static body_set_param(body: RID, param: PhysicsServer2D.BodyParameter, value: any): void
/** Returns the value of the given body parameter. See [enum BodyParameter] for the list of available parameters. */
static body_get_param(body: RID, param: PhysicsServer2D.BodyParameter): any
/** Restores the default inertia and center of mass of the body based on its shapes. This undoes any custom values previously set using [method body_set_param]. */
static body_reset_mass_properties(body: RID): void
/** Sets the value of a body's state. See [enum BodyState] for the list of available states.
*
* **Note:** The state change doesn't take effect immediately. The state will change on the next physics frame.
*/
static body_set_state(body: RID, state: PhysicsServer2D.BodyState, value: any): void
/** Returns the value of the given state of the body. See [enum BodyState] for the list of available states. */
static body_get_state(body: RID, state: PhysicsServer2D.BodyState): any
/** Applies a directional impulse to the body, at the body's center of mass. The impulse does not affect rotation.
* An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
* This is equivalent to using [method body_apply_impulse] at the body's center of mass.
*/
static body_apply_central_impulse(body: RID, impulse: Vector2): void
/** Applies a rotational impulse to the body. The impulse does not affect position.
* An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
*/
static body_apply_torque_impulse(body: RID, impulse: float64): void
/** Applies a positioned impulse to the body. The impulse can affect rotation if [param position] is different from the body's center of mass.
* An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
* [param position] is the offset from the body origin in global coordinates.
*/
static body_apply_impulse(body: RID, impulse: Vector2, position: Vector2 = Vector2.ZERO): void
/** Applies a directional force to the body, at the body's center of mass. The force does not affect rotation. A force is time dependent and meant to be applied every physics update.
* This is equivalent to using [method body_apply_force] at the body's center of mass.
*/
static body_apply_central_force(body: RID, force: Vector2): void
/** Applies a positioned force to the body. The force can affect rotation if [param position] is different from the body's center of mass. A force is time dependent and meant to be applied every physics update.
* [param position] is the offset from the body origin in global coordinates.
*/
static body_apply_force(body: RID, force: Vector2, position: Vector2 = Vector2.ZERO): void
/** Applies a rotational force to the body. The force does not affect position. A force is time dependent and meant to be applied every physics update. */
static body_apply_torque(body: RID, torque: float64): void
/** Adds a constant directional force to the body. The force does not affect rotation. The force remains applied over time until cleared with `PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))`.
* This is equivalent to using [method body_add_constant_force] at the body's center of mass.
*/
static body_add_constant_central_force(body: RID, force: Vector2): void
/** Adds a constant positioned force to the body. The force can affect rotation if [param position] is different from the body's center of mass. The force remains applied over time until cleared with `PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))`.
* [param position] is the offset from the body origin in global coordinates.
*/
static body_add_constant_force(body: RID, force: Vector2, position: Vector2 = Vector2.ZERO): void
/** Adds a constant rotational force to the body. The force does not affect position. The force remains applied over time until cleared with `PhysicsServer2D.body_set_constant_torque(body, 0)`. */
static body_add_constant_torque(body: RID, torque: float64): void
/** Sets the body's total constant positional force applied during each physics update.
* See [method body_add_constant_force] and [method body_add_constant_central_force].
*/
static body_set_constant_force(body: RID, force: Vector2): void
/** Returns the body's total constant positional force applied during each physics update.
* See [method body_add_constant_force] and [method body_add_constant_central_force].
*/
static body_get_constant_force(body: RID): Vector2
/** Sets the body's total constant rotational force applied during each physics update.
* See [method body_add_constant_torque].
*/
static body_set_constant_torque(body: RID, torque: float64): void
/** Returns the body's total constant rotational force applied during each physics update.
* See [method body_add_constant_torque].
*/
static body_get_constant_torque(body: RID): float64
/** Modifies the body's linear velocity so that its projection to the axis `axis_velocity.normalized()` is exactly `axis_velocity.length()`. This is useful for jumping behavior. */
static body_set_axis_velocity(body: RID, axis_velocity: Vector2): void
/** Adds [param excepted_body] to the body's list of collision exceptions, so that collisions with it are ignored. */
static body_add_collision_exception(body: RID, excepted_body: RID): void
/** Removes [param excepted_body] from the body's list of collision exceptions, so that collisions with it are no longer ignored. */
static body_remove_collision_exception(body: RID, excepted_body: RID): void
/** Sets the maximum number of contacts that the body can report. If [param amount] is greater than zero, then the body will keep track of at most this many contacts with other bodies. */
static body_set_max_contacts_reported(body: RID, amount: int64): void
/** Returns the maximum number of contacts that the body can report. See [method body_set_max_contacts_reported]. */
static body_get_max_contacts_reported(body: RID): int64
/** Sets whether the body omits the standard force integration. If [param enable] is `true`, the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, [method body_set_force_integration_callback] can be used to manually update the linear and angular velocity instead.
* This method is called when the property [member RigidBody2D.custom_integrator] is set.
*/
static body_set_omit_force_integration(body: RID, enable: boolean): void
/** Returns `true` if the body is omitting the standard force integration. See [method body_set_omit_force_integration]. */
static body_is_omitting_force_integration(body: RID): boolean
/** Sets the body's state synchronization callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()`) to clear the callback.
* The function [param callable] will be called every physics frame, assuming that the body was active during the previous physics tick, and can be used to fetch the latest state from the physics server.
* The function [param callable] must take the following parameters:
* 1. `state`: a [PhysicsDirectBodyState2D], used to retrieve the body's state.
*/
static body_set_state_sync_callback(body: RID, callable: Callable): void
/** Sets the body's custom force integration callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()`) to clear the custom callback.
* The function [param callable] will be called every physics tick, before the standard force integration (see [method body_set_omit_force_integration]). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
* If [param userdata] is not `null`, the function [param callable] must take the following two parameters:
* 1. `state`: a [PhysicsDirectBodyState2D] used to retrieve and modify the body's state,
* 2. [code skip-lint]userdata`: a [Variant]; its value will be the [param userdata] passed into this method.
* If [param userdata] is `null`, then [param callable] must take only the `state` parameter.
*/
static body_set_force_integration_callback(body: RID, callable: Callable, userdata: any = {}): void
/** Returns `true` if a collision would result from moving the body along a motion vector from a given point in space. See [PhysicsTestMotionParameters2D] for the available motion parameters. Optionally a [PhysicsTestMotionResult2D] object can be passed, which will be used to store the information about the resulting collision. */
static body_test_motion(body: RID, parameters: PhysicsTestMotionParameters2D, result: PhysicsTestMotionResult2D = undefined): boolean
/** Returns the [PhysicsDirectBodyState2D] of the body. Returns `null` if the body is destroyed or not assigned to a space. */
static body_get_direct_state(body: RID): PhysicsDirectBodyState2D
/** Creates a 2D joint in the physics server, and returns the [RID] that identifies it. To set the joint type, use [method joint_make_damped_spring], [method joint_make_groove] or [method joint_make_pin]. Use [method joint_set_param] to set generic joint parameters. */
static joint_create(): RID
/** Destroys the joint with the given [RID], creates a new uninitialized joint, and makes the [RID] refer to this new joint. */
static joint_clear(joint: RID): void
/** Sets the value of the given joint parameter. See [enum JointParam] for the list of available parameters. */
static joint_set_param(joint: RID, param: PhysicsServer2D.JointParam, value: float64): void
/** Returns the value of the given joint parameter. See [enum JointParam] for the list of available parameters. */
static joint_get_param(joint: RID, param: PhysicsServer2D.JointParam): float64
/** Sets whether the bodies attached to the [Joint2D] will collide with each other. */
static joint_disable_collisions_between_bodies(joint: RID, disable: boolean): void
/** Returns whether the bodies attached to the [Joint2D] will collide with each other. */
static joint_is_disabled_collisions_between_bodies(joint: RID): boolean
/** Makes the joint a pin joint. If [param body_b] is an empty [RID], then [param body_a] is pinned to the point [param anchor] (given in global coordinates); otherwise, [param body_a] is pinned to [param body_b] at the point [param anchor] (given in global coordinates). To set the parameters which are specific to the pin joint, see [method pin_joint_set_param]. */
static joint_make_pin(joint: RID, anchor: Vector2, body_a: RID, body_b: RID = new RID()): void
/** Makes the joint a groove joint. */
static joint_make_groove(joint: RID, groove1_a: Vector2, groove2_a: Vector2, anchor_b: Vector2, body_a: RID = new RID(), body_b: RID = new RID()): void
/** Makes the joint a damped spring joint, attached at the point [param anchor_a] (given in global coordinates) on the body [param body_a] and at the point [param anchor_b] (given in global coordinates) on the body [param body_b]. To set the parameters which are specific to the damped spring, see [method damped_spring_joint_set_param]. */
static joint_make_damped_spring(joint: RID, anchor_a: Vector2, anchor_b: Vector2, body_a: RID, body_b: RID = new RID()): void
/** Sets a pin joint flag (see [enum PinJointFlag] constants). */
static pin_joint_set_flag(joint: RID, flag: PhysicsServer2D.PinJointFlag, enabled: boolean): void
/** Gets a pin joint flag (see [enum PinJointFlag] constants). */
static pin_joint_get_flag(joint: RID, flag: PhysicsServer2D.PinJointFlag): boolean
/** Sets a pin joint parameter. See [enum PinJointParam] for a list of available parameters. */
static pin_joint_set_param(joint: RID, param: PhysicsServer2D.PinJointParam, value: float64): void
/** Returns the value of a pin joint parameter. See [enum PinJointParam] for a list of available parameters. */
static pin_joint_get_param(joint: RID, param: PhysicsServer2D.PinJointParam): float64
/** Sets the value of the given damped spring joint parameter. See [enum DampedSpringParam] for the list of available parameters. */
static damped_spring_joint_set_param(joint: RID, param: PhysicsServer2D.DampedSpringParam, value: float64): void
/** Returns the value of the given damped spring joint parameter. See [enum DampedSpringParam] for the list of available parameters. */
static damped_spring_joint_get_param(joint: RID, param: PhysicsServer2D.DampedSpringParam): float64
/** Returns the joint's type (see [enum JointType]). */
static joint_get_type(joint: RID): PhysicsServer2D.JointType
/** Destroys any of the objects created by PhysicsServer2D. If the [RID] passed is not one of the objects that can be created by PhysicsServer2D, an error will be printed to the console. */
static free_rid(rid: RID): void
/** Activates or deactivates the 2D physics server. If [param active] is `false`, then the physics server will not do anything in its physics step. */
static set_active(active: boolean): void
/** Returns information about the current state of the 2D physics engine. See [enum ProcessInfo] for the list of available states. */
static get_process_info(process_info: PhysicsServer2D.ProcessInfo): int64
}
// _singleton_class_: PhysicsServer3D
namespace PhysicsServer3D {
enum JointType {
/** The [Joint3D] is a [PinJoint3D]. */
JOINT_TYPE_PIN = 0,
/** The [Joint3D] is a [HingeJoint3D]. */
JOINT_TYPE_HINGE = 1,
/** The [Joint3D] is a [SliderJoint3D]. */
JOINT_TYPE_SLIDER = 2,
/** The [Joint3D] is a [ConeTwistJoint3D]. */
JOINT_TYPE_CONE_TWIST = 3,
/** The [Joint3D] is a [Generic6DOFJoint3D]. */
JOINT_TYPE_6DOF = 4,
/** Represents the size of the [enum JointType] enum. */
JOINT_TYPE_MAX = 5,
}
enum PinJointParam {
/** The strength with which the pinned objects try to stay in positional relation to each other.
* The higher, the stronger.
*/
PIN_JOINT_BIAS = 0,
/** The strength with which the pinned objects try to stay in velocity relation to each other.
* The higher, the stronger.
*/
PIN_JOINT_DAMPING = 1,
/** If above 0, this value is the maximum value for an impulse that this Joint3D puts on its ends. */
PIN_JOINT_IMPULSE_CLAMP = 2,
}
enum HingeJointParam {
/** The speed with which the two bodies get pulled together when they move in different directions. */
HINGE_JOINT_BIAS = 0,
/** The maximum rotation across the Hinge. */
HINGE_JOINT_LIMIT_UPPER = 1,
/** The minimum rotation across the Hinge. */
HINGE_JOINT_LIMIT_LOWER = 2,
/** The speed with which the rotation across the axis perpendicular to the hinge gets corrected. */
HINGE_JOINT_LIMIT_BIAS = 3,
HINGE_JOINT_LIMIT_SOFTNESS = 4,
/** The lower this value, the more the rotation gets slowed down. */
HINGE_JOINT_LIMIT_RELAXATION = 5,
/** Target speed for the motor. */
HINGE_JOINT_MOTOR_TARGET_VELOCITY = 6,
/** Maximum acceleration for the motor. */
HINGE_JOINT_MOTOR_MAX_IMPULSE = 7,
}
enum HingeJointFlag {
/** If `true`, the Hinge has a maximum and a minimum rotation. */
HINGE_JOINT_FLAG_USE_LIMIT = 0,
/** If `true`, a motor turns the Hinge. */
HINGE_JOINT_FLAG_ENABLE_MOTOR = 1,
}
enum SliderJointParam {
/** The maximum difference between the pivot points on their X axis before damping happens. */
SLIDER_JOINT_LINEAR_LIMIT_UPPER = 0,
/** The minimum difference between the pivot points on their X axis before damping happens. */
SLIDER_JOINT_LINEAR_LIMIT_LOWER = 1,
/** A factor applied to the movement across the slider axis once the limits get surpassed. The lower, the slower the movement. */
SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS = 2,
/** The amount of restitution once the limits are surpassed. The lower, the more velocity-energy gets lost. */
SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION = 3,
/** The amount of damping once the slider limits are surpassed. */
SLIDER_JOINT_LINEAR_LIMIT_DAMPING = 4,
/** A factor applied to the movement across the slider axis as long as the slider is in the limits. The lower, the slower the movement. */
SLIDER_JOINT_LINEAR_MOTION_SOFTNESS = 5,
/** The amount of restitution inside the slider limits. */
SLIDER_JOINT_LINEAR_MOTION_RESTITUTION = 6,
/** The amount of damping inside the slider limits. */
SLIDER_JOINT_LINEAR_MOTION_DAMPING = 7,
/** A factor applied to the movement across axes orthogonal to the slider. */
SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS = 8,
/** The amount of restitution when movement is across axes orthogonal to the slider. */
SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION = 9,
/** The amount of damping when movement is across axes orthogonal to the slider. */
SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING = 10,
/** The upper limit of rotation in the slider. */
SLIDER_JOINT_ANGULAR_LIMIT_UPPER = 11,
/** The lower limit of rotation in the slider. */
SLIDER_JOINT_ANGULAR_LIMIT_LOWER = 12,
/** A factor applied to the all rotation once the limit is surpassed. */
SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS = 13,
/** The amount of restitution of the rotation when the limit is surpassed. */
SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION = 14,
/** The amount of damping of the rotation when the limit is surpassed. */
SLIDER_JOINT_ANGULAR_LIMIT_DAMPING = 15,
/** A factor that gets applied to the all rotation in the limits. */
SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS = 16,
/** The amount of restitution of the rotation in the limits. */
SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION = 17,
/** The amount of damping of the rotation in the limits. */
SLIDER_JOINT_ANGULAR_MOTION_DAMPING = 18,
/** A factor that gets applied to the all rotation across axes orthogonal to the slider. */
SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS = 19,
/** The amount of restitution of the rotation across axes orthogonal to the slider. */
SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION = 20,
/** The amount of damping of the rotation across axes orthogonal to the slider. */
SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING = 21,
/** Represents the size of the [enum SliderJointParam] enum. */
SLIDER_JOINT_MAX = 22,
}
enum ConeTwistJointParam {
/** Swing is rotation from side to side, around the axis perpendicular to the twist axis.
* The swing span defines, how much rotation will not get corrected along the swing axis.
* Could be defined as looseness in the [ConeTwistJoint3D].
* If below 0.05, this behavior is locked.
*/
CONE_TWIST_JOINT_SWING_SPAN = 0,
/** Twist is the rotation around the twist axis, this value defined how far the joint can twist.
* Twist is locked if below 0.05.
*/
CONE_TWIST_JOINT_TWIST_SPAN = 1,
/** The speed with which the swing or twist will take place.
* The higher, the faster.
*/
CONE_TWIST_JOINT_BIAS = 2,
/** The ease with which the Joint3D twists, if it's too low, it takes more force to twist the joint. */
CONE_TWIST_JOINT_SOFTNESS = 3,
/** Defines, how fast the swing- and twist-speed-difference on both sides gets synced. */
CONE_TWIST_JOINT_RELAXATION = 4,
}
enum G6DOFJointAxisParam {
/** The minimum difference between the pivot points' axes. */
G6DOF_JOINT_LINEAR_LOWER_LIMIT = 0,
/** The maximum difference between the pivot points' axes. */
G6DOF_JOINT_LINEAR_UPPER_LIMIT = 1,
/** A factor that gets applied to the movement across the axes. The lower, the slower the movement. */
G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS = 2,
/** The amount of restitution on the axes movement. The lower, the more velocity-energy gets lost. */
G6DOF_JOINT_LINEAR_RESTITUTION = 3,
/** The amount of damping that happens at the linear motion across the axes. */
G6DOF_JOINT_LINEAR_DAMPING = 4,
/** The velocity that the joint's linear motor will attempt to reach. */
G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY = 5,
/** The maximum force that the linear motor can apply while trying to reach the target velocity. */
G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT = 6,
G6DOF_JOINT_LINEAR_SPRING_STIFFNESS = 7,
G6DOF_JOINT_LINEAR_SPRING_DAMPING = 8,
G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT = 9,
/** The minimum rotation in negative direction to break loose and rotate around the axes. */
G6DOF_JOINT_ANGULAR_LOWER_LIMIT = 10,
/** The minimum rotation in positive direction to break loose and rotate around the axes. */
G6DOF_JOINT_ANGULAR_UPPER_LIMIT = 11,
/** A factor that gets multiplied onto all rotations across the axes. */
G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS = 12,
/** The amount of rotational damping across the axes. The lower, the more damping occurs. */
G6DOF_JOINT_ANGULAR_DAMPING = 13,
/** The amount of rotational restitution across the axes. The lower, the more restitution occurs. */
G6DOF_JOINT_ANGULAR_RESTITUTION = 14,
/** The maximum amount of force that can occur, when rotating around the axes. */
G6DOF_JOINT_ANGULAR_FORCE_LIMIT = 15,
/** When correcting the crossing of limits in rotation across the axes, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower. */
G6DOF_JOINT_ANGULAR_ERP = 16,
/** Target speed for the motor at the axes. */
G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY = 17,
/** Maximum acceleration for the motor at the axes. */
G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT = 18,
G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS = 19,
G6DOF_JOINT_ANGULAR_SPRING_DAMPING = 20,
G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT = 21,
/** Represents the size of the [enum G6DOFJointAxisParam] enum. */
G6DOF_JOINT_MAX = 22,
}
enum G6DOFJointAxisFlag {
/** If set, linear motion is possible within the given limits. */
G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT = 0,
/** If set, rotational motion is possible. */
G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT = 1,
G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING = 2,
G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING = 3,
/** If set, there is a rotational motor across these axes. */
G6DOF_JOINT_FLAG_ENABLE_MOTOR = 4,
/** If set, there is a linear motor on this axis that targets a specific velocity. */
G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR = 5,
/** Represents the size of the [enum G6DOFJointAxisFlag] enum. */
G6DOF_JOINT_FLAG_MAX = 6,
}
enum ShapeType {
/** The [Shape3D] is a [WorldBoundaryShape3D]. */
SHAPE_WORLD_BOUNDARY = 0,
/** The [Shape3D] is a [SeparationRayShape3D]. */
SHAPE_SEPARATION_RAY = 1,
/** The [Shape3D] is a [SphereShape3D]. */
SHAPE_SPHERE = 2,
/** The [Shape3D] is a [BoxShape3D]. */
SHAPE_BOX = 3,
/** The [Shape3D] is a [CapsuleShape3D]. */
SHAPE_CAPSULE = 4,
/** The [Shape3D] is a [CylinderShape3D]. */
SHAPE_CYLINDER = 5,
/** The [Shape3D] is a [ConvexPolygonShape3D]. */
SHAPE_CONVEX_POLYGON = 6,
/** The [Shape3D] is a [ConcavePolygonShape3D]. */
SHAPE_CONCAVE_POLYGON = 7,
/** The [Shape3D] is a [HeightMapShape3D]. */
SHAPE_HEIGHTMAP = 8,
/** The [Shape3D] is used internally for a soft body. Any attempt to create this kind of shape results in an error. */
SHAPE_SOFT_BODY = 9,
/** This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. */
SHAPE_CUSTOM = 10,
}
enum AreaParameter {
/** Constant to set/get gravity override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. */
AREA_PARAM_GRAVITY_OVERRIDE_MODE = 0,
/** Constant to set/get gravity strength in an area. */
AREA_PARAM_GRAVITY = 1,
/** Constant to set/get gravity vector/center in an area. */
AREA_PARAM_GRAVITY_VECTOR = 2,
/** Constant to set/get whether the gravity vector of an area is a direction, or a center point. */
AREA_PARAM_GRAVITY_IS_POINT = 3,
/** Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by [constant AREA_PARAM_GRAVITY]. For example, on a planet 100 meters in radius with a surface gravity of 4.0 m/s², set the gravity to 4.0 and the unit distance to 100.0. The gravity will have falloff according to the inverse square law, so in the example, at 200 meters from the center the gravity will be 1.0 m/s² (twice the distance, 1/4th the gravity), at 50 meters it will be 16.0 m/s² (half the distance, 4x the gravity), and so on.
* The above is true only when the unit distance is a positive number. When this is set to 0.0, the gravity will be constant regardless of distance.
*/
AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE = 4,
/** Constant to set/get linear damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. */
AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE = 5,
/** Constant to set/get the linear damping factor of an area. */
AREA_PARAM_LINEAR_DAMP = 6,
/** Constant to set/get angular damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. */
AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE = 7,
/** Constant to set/get the angular damping factor of an area. */
AREA_PARAM_ANGULAR_DAMP = 8,
/** Constant to set/get the priority (order of processing) of an area. */
AREA_PARAM_PRIORITY = 9,
/** Constant to set/get the magnitude of area-specific wind force. This wind force only applies to [SoftBody3D] nodes. Other physics bodies are currently not affected by wind. */
AREA_PARAM_WIND_FORCE_MAGNITUDE = 10,
/** Constant to set/get the 3D vector that specifies the origin from which an area-specific wind blows. */
AREA_PARAM_WIND_SOURCE = 11,
/** Constant to set/get the 3D vector that specifies the direction in which an area-specific wind blows. */
AREA_PARAM_WIND_DIRECTION = 12,
/** Constant to set/get the exponential rate at which wind force decreases with distance from its origin. */
AREA_PARAM_WIND_ATTENUATION_FACTOR = 13,
}
enum AreaSpaceOverrideMode {
/** This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them. */
AREA_SPACE_OVERRIDE_DISABLED = 0,
/** This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects. */
AREA_SPACE_OVERRIDE_COMBINE = 1,
/** This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one. */
AREA_SPACE_OVERRIDE_COMBINE_REPLACE = 2,
/** This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas. */
AREA_SPACE_OVERRIDE_REPLACE = 3,
/** This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one. */
AREA_SPACE_OVERRIDE_REPLACE_COMBINE = 4,
}
enum BodyMode {
/** Constant for static bodies. In this mode, a body can be only moved by user code and doesn't collide with other bodies along its path when moved. */
BODY_MODE_STATIC = 0,
/** Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path. */
BODY_MODE_KINEMATIC = 1,
/** Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied. */
BODY_MODE_RIGID = 2,
/** Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces. */
BODY_MODE_RIGID_LINEAR = 3,
}
enum BodyParameter {
/** Constant to set/get a body's bounce factor. */
BODY_PARAM_BOUNCE = 0,
/** Constant to set/get a body's friction. */
BODY_PARAM_FRICTION = 1,
/** Constant to set/get a body's mass. */
BODY_PARAM_MASS = 2,
/** Constant to set/get a body's inertia. */
BODY_PARAM_INERTIA = 3,
/** Constant to set/get a body's center of mass position in the body's local coordinate system. */
BODY_PARAM_CENTER_OF_MASS = 4,
/** Constant to set/get a body's gravity multiplier. */
BODY_PARAM_GRAVITY_SCALE = 5,
/** Constant to set/get a body's linear damping mode. See [enum BodyDampMode] for possible values. */
BODY_PARAM_LINEAR_DAMP_MODE = 6,
/** Constant to set/get a body's angular damping mode. See [enum BodyDampMode] for possible values. */
BODY_PARAM_ANGULAR_DAMP_MODE = 7,
/** Constant to set/get a body's linear damping factor. */
BODY_PARAM_LINEAR_DAMP = 8,
/** Constant to set/get a body's angular damping factor. */
BODY_PARAM_ANGULAR_DAMP = 9,
/** Represents the size of the [enum BodyParameter] enum. */
BODY_PARAM_MAX = 10,
}
enum BodyDampMode {
/** The body's damping value is added to any value set in areas or the default value. */
BODY_DAMP_MODE_COMBINE = 0,
/** The body's damping value replaces any value set in areas or the default value. */
BODY_DAMP_MODE_REPLACE = 1,
}
enum BodyState {
/** Constant to set/get the current transform matrix of the body. */
BODY_STATE_TRANSFORM = 0,
/** Constant to set/get the current linear velocity of the body. */
BODY_STATE_LINEAR_VELOCITY = 1,
/** Constant to set/get the current angular velocity of the body. */
BODY_STATE_ANGULAR_VELOCITY = 2,
/** Constant to sleep/wake up a body, or to get whether it is sleeping. */
BODY_STATE_SLEEPING = 3,
/** Constant to set/get whether the body can sleep. */
BODY_STATE_CAN_SLEEP = 4,
}
enum AreaBodyStatus {
/** The value of the first parameter and area callback function receives, when an object enters one of its shapes. */
AREA_BODY_ADDED = 0,
/** The value of the first parameter and area callback function receives, when an object exits one of its shapes. */
AREA_BODY_REMOVED = 1,
}
enum ProcessInfo {
/** Constant to get the number of objects that are not sleeping. */
INFO_ACTIVE_OBJECTS = 0,
/** Constant to get the number of possible collisions. */
INFO_COLLISION_PAIRS = 1,
/** Constant to get the number of space regions where a collision could occur. */
INFO_ISLAND_COUNT = 2,
}
enum SpaceParameter {
/** Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated. */
SPACE_PARAM_CONTACT_RECYCLE_RADIUS = 0,
/** Constant to set/get the maximum distance a shape can be from another before they are considered separated and the contact is discarded. */
SPACE_PARAM_CONTACT_MAX_SEPARATION = 1,
/** Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision. */
SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION = 2,
/** Constant to set/get the default solver bias for all physics contacts. A solver bias is a factor controlling how much two objects "rebound", after overlapping, to avoid leaving them in that state because of numerical imprecision. */
SPACE_PARAM_CONTACT_DEFAULT_BIAS = 3,
/** Constant to set/get the threshold linear velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given. */
SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD = 4,
/** Constant to set/get the threshold angular velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given. */
SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD = 5,
/** Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time. */
SPACE_PARAM_BODY_TIME_TO_SLEEP = 6,
/** Constant to set/get the number of solver iterations for contacts and constraints. The greater the number of iterations, the more accurate the collisions and constraints will be. However, a greater number of iterations requires more CPU power, which can decrease performance. */
SPACE_PARAM_SOLVER_ITERATIONS = 7,
}
enum BodyAxis {
BODY_AXIS_LINEAR_X = 1,
BODY_AXIS_LINEAR_Y = 2,
BODY_AXIS_LINEAR_Z = 4,
BODY_AXIS_ANGULAR_X = 8,
BODY_AXIS_ANGULAR_Y = 16,
BODY_AXIS_ANGULAR_Z = 32,
}
}
/** A server interface for low-level 3D physics access.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_physicsserver3d.html
*/
class PhysicsServer3D extends Object {
static world_boundary_shape_create(): RID
static separation_ray_shape_create(): RID
static sphere_shape_create(): RID
static box_shape_create(): RID
static capsule_shape_create(): RID
static cylinder_shape_create(): RID
static convex_polygon_shape_create(): RID
static concave_polygon_shape_create(): RID
static heightmap_shape_create(): RID
static custom_shape_create(): RID
/** Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type]. */
static shape_set_data(shape: RID, data: any): void
/** Sets the collision margin for the shape.
*
* **Note:** This is not used in Godot Physics.
*/
static shape_set_margin(shape: RID, margin: float64): void
/** Returns the type of shape (see [enum ShapeType] constants). */
static shape_get_type(shape: RID): PhysicsServer3D.ShapeType
/** Returns the shape data. */
static shape_get_data(shape: RID): any
/** Returns the collision margin for the shape.
*
* **Note:** This is not used in Godot Physics, so will always return `0`.
*/
static shape_get_margin(shape: RID): float64
/** Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with [method area_set_space], or to a body with [method body_set_space]. */
static space_create(): RID
/** Marks a space as active. It will not have an effect, unless it is assigned to an area or body. */
static space_set_active(space: RID, active: boolean): void
/** Returns whether the space is active. */
static space_is_active(space: RID): boolean
/** Sets the value for a space parameter. A list of available parameters is on the [enum SpaceParameter] constants. */
static space_set_param(space: RID, param: PhysicsServer3D.SpaceParameter, value: float64): void
/** Returns the value of a space parameter. */
static space_get_param(space: RID, param: PhysicsServer3D.SpaceParameter): float64
/** Returns the state of a space, a [PhysicsDirectSpaceState3D]. This object can be used to make collision/intersection queries. */
static space_get_direct_state(space: RID): PhysicsDirectSpaceState3D
/** Creates a 3D area object in the physics server, and returns the [RID] that identifies it. The default settings for the created area include a collision layer and mask set to `1`, and `monitorable` set to `false`.
* Use [method area_add_shape] to add shapes to it, use [method area_set_transform] to set its transform, and use [method area_set_space] to add the area to a space. If you want the area to be detectable use [method area_set_monitorable].
*/
static area_create(): RID
/** Assigns a space to the area. */
static area_set_space(area: RID, space: RID): void
/** Returns the space assigned to the area. */
static area_get_space(area: RID): RID
/** Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. */
static area_add_shape(area: RID, shape: RID, transform: Transform3D = new Transform3D(), disabled: boolean = false): void
/** Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID]. */
static area_set_shape(area: RID, shape_idx: int64, shape: RID): void
/** Sets the transform matrix for an area shape. */
static area_set_shape_transform(area: RID, shape_idx: int64, transform: Transform3D): void
static area_set_shape_disabled(area: RID, shape_idx: int64, disabled: boolean): void
/** Returns the number of shapes assigned to an area. */
static area_get_shape_count(area: RID): int64
/** Returns the [RID] of the nth shape of an area. */
static area_get_shape(area: RID, shape_idx: int64): RID
/** Returns the transform matrix of a shape within an area. */
static area_get_shape_transform(area: RID, shape_idx: int64): Transform3D
/** Removes a shape from an area. It does not delete the shape, so it can be reassigned later. */
static area_remove_shape(area: RID, shape_idx: int64): void
/** Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later. */
static area_clear_shapes(area: RID): void
/** Assigns the area to one or many physics layers. */
static area_set_collision_layer(area: RID, layer: int64): void
/** Returns the physics layer or layers an area belongs to. */
static area_get_collision_layer(area: RID): int64
/** Sets which physics layers the area will monitor. */
static area_set_collision_mask(area: RID, mask: int64): void
/** Returns the physics layer or layers an area can contact with. */
static area_get_collision_mask(area: RID): int64
/** Sets the value for an area parameter. A list of available parameters is on the [enum AreaParameter] constants. */
static area_set_param(area: RID, param: PhysicsServer3D.AreaParameter, value: any): void
/** Sets the transform matrix for an area. */
static area_set_transform(area: RID, transform: Transform3D): void
/** Returns an area parameter value. A list of available parameters is on the [enum AreaParameter] constants. */
static area_get_param(area: RID, param: PhysicsServer3D.AreaParameter): any
/** Returns the transform matrix for an area. */
static area_get_transform(area: RID): Transform3D
/** Assigns the area to a descendant of [Object], so it can exist in the node tree. */
static area_attach_object_instance_id(area: RID, id: int64): void
/** Gets the instance ID of the object the area is assigned to. */
static area_get_object_instance_id(area: RID): int64
/** Sets the area's body monitor callback. This callback will be called when any other (shape of a) body enters or exits (a shape of) the given area, and must take the following five parameters:
* 1. an integer `status`: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other body shape entered or exited the area,
* 2. an [RID] `body_rid`: the [RID] of the body that entered or exited the area,
* 3. an integer `instance_id`: the `ObjectID` attached to the body,
* 4. an integer `body_shape_idx`: the index of the shape of the body that entered or exited the area,
* 5. an integer `self_shape_idx`: the index of the shape of the area where the body entered or exited.
* By counting (or keeping track of) the shapes that enter and exit, it can be determined if a body (with all its shapes) is entering for the first time or exiting for the last time.
*/
static area_set_monitor_callback(area: RID, callback: Callable): void
/** Sets the area's area monitor callback. This callback will be called when any other (shape of an) area enters or exits (a shape of) the given area, and must take the following five parameters:
* 1. an integer `status`: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other area's shape entered or exited the area,
* 2. an [RID] `area_rid`: the [RID] of the other area that entered or exited the area,
* 3. an integer `instance_id`: the `ObjectID` attached to the other area,
* 4. an integer `area_shape_idx`: the index of the shape of the other area that entered or exited the area,
* 5. an integer `self_shape_idx`: the index of the shape of the area where the other area entered or exited.
* By counting (or keeping track of) the shapes that enter and exit, it can be determined if an area (with all its shapes) is entering for the first time or exiting for the last time.
*/
static area_set_area_monitor_callback(area: RID, callback: Callable): void
static area_set_monitorable(area: RID, monitorable: boolean): void
/** Sets object pickable with rays. */
static area_set_ray_pickable(area: RID, enable: boolean): void
/** Creates a 3D body object in the physics server, and returns the [RID] that identifies it. The default settings for the created area include a collision layer and mask set to `1`, and body mode set to [constant BODY_MODE_RIGID].
* Use [method body_add_shape] to add shapes to it, use [method body_set_state] to set its transform, and use [method body_set_space] to add the body to a space.
*/
static body_create(): RID
/** Assigns a space to the body (see [method space_create]). */
static body_set_space(body: RID, space: RID): void
/** Returns the [RID] of the space assigned to a body. */
static body_get_space(body: RID): RID
/** Sets the body mode, from one of the [enum BodyMode] constants. */
static body_set_mode(body: RID, mode: PhysicsServer3D.BodyMode): void
/** Returns the body mode. */
static body_get_mode(body: RID): PhysicsServer3D.BodyMode
/** Sets the physics layer or layers a body belongs to. */
static body_set_collision_layer(body: RID, layer: int64): void
/** Returns the physics layer or layers a body belongs to. */
static body_get_collision_layer(body: RID): int64
/** Sets the physics layer or layers a body can collide with. */
static body_set_collision_mask(body: RID, mask: int64): void
/** Returns the physics layer or layers a body can collide with. */
static body_get_collision_mask(body: RID): int64
/** Sets the body's collision priority. */
static body_set_collision_priority(body: RID, priority: float64): void
/** Returns the body's collision priority. */
static body_get_collision_priority(body: RID): float64
/** Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. */
static body_add_shape(body: RID, shape: RID, transform: Transform3D = new Transform3D(), disabled: boolean = false): void
/** Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID]. */
static body_set_shape(body: RID, shape_idx: int64, shape: RID): void
/** Sets the transform matrix for a body shape. */
static body_set_shape_transform(body: RID, shape_idx: int64, transform: Transform3D): void
static body_set_shape_disabled(body: RID, shape_idx: int64, disabled: boolean): void
/** Returns the number of shapes assigned to a body. */
static body_get_shape_count(body: RID): int64
/** Returns the [RID] of the nth shape of a body. */
static body_get_shape(body: RID, shape_idx: int64): RID
/** Returns the transform matrix of a body shape. */
static body_get_shape_transform(body: RID, shape_idx: int64): Transform3D
/** Removes a shape from a body. The shape is not deleted, so it can be reused afterwards. */
static body_remove_shape(body: RID, shape_idx: int64): void
/** Removes all shapes from a body. */
static body_clear_shapes(body: RID): void
/** Assigns the area to a descendant of [Object], so it can exist in the node tree. */
static body_attach_object_instance_id(body: RID, id: int64): void
/** Gets the instance ID of the object the area is assigned to. */
static body_get_object_instance_id(body: RID): int64
/** If `true`, the continuous collision detection mode is enabled.
* Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
*/
static body_set_enable_continuous_collision_detection(body: RID, enable: boolean): void
/** If `true`, the continuous collision detection mode is enabled. */
static body_is_continuous_collision_detection_enabled(body: RID): boolean
/** Sets a body parameter. A list of available parameters is on the [enum BodyParameter] constants. */
static body_set_param(body: RID, param: PhysicsServer3D.BodyParameter, value: any): void
/** Returns the value of a body parameter. A list of available parameters is on the [enum BodyParameter] constants. */
static body_get_param(body: RID, param: PhysicsServer3D.BodyParameter): any
/** Restores the default inertia and center of mass based on shapes to cancel any custom values previously set using [method body_set_param]. */
static body_reset_mass_properties(body: RID): void
/** Sets a body state (see [enum BodyState] constants). */
static body_set_state(body: RID, state: PhysicsServer3D.BodyState, value: any): void
/** Returns a body state. */
static body_get_state(body: RID, state: PhysicsServer3D.BodyState): any
/** Applies a directional impulse without affecting rotation.
* An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
* This is equivalent to using [method body_apply_impulse] at the body's center of mass.
*/
static body_apply_central_impulse(body: RID, impulse: Vector3): void
/** Applies a positioned impulse to the body.
* An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
* [param position] is the offset from the body origin in global coordinates.
*/
static body_apply_impulse(body: RID, impulse: Vector3, position: Vector3 = new Vector3(0, 0, 0)): void
/** Applies a rotational impulse to the body without affecting the position.
* An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
*/
static body_apply_torque_impulse(body: RID, impulse: Vector3): void
/** Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
* This is equivalent to using [method body_apply_force] at the body's center of mass.
*/
static body_apply_central_force(body: RID, force: Vector3): void
/** Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
* [param position] is the offset from the body origin in global coordinates.
*/
static body_apply_force(body: RID, force: Vector3, position: Vector3 = new Vector3(0, 0, 0)): void
/** Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update. */
static body_apply_torque(body: RID, torque: Vector3): void
/** Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with `body_set_constant_force(body, Vector3(0, 0, 0))`.
* This is equivalent to using [method body_add_constant_force] at the body's center of mass.
*/
static body_add_constant_central_force(body: RID, force: Vector3): void
/** Adds a constant positioned force to the body that keeps being applied over time until cleared with `body_set_constant_force(body, Vector3(0, 0, 0))`.
* [param position] is the offset from the body origin in global coordinates.
*/
static body_add_constant_force(body: RID, force: Vector3, position: Vector3 = new Vector3(0, 0, 0)): void
/** Adds a constant rotational force without affecting position that keeps being applied over time until cleared with `body_set_constant_torque(body, Vector3(0, 0, 0))`. */
static body_add_constant_torque(body: RID, torque: Vector3): void
/** Sets the body's total constant positional forces applied during each physics update.
* See [method body_add_constant_force] and [method body_add_constant_central_force].
*/
static body_set_constant_force(body: RID, force: Vector3): void
/** Returns the body's total constant positional forces applied during each physics update.
* See [method body_add_constant_force] and [method body_add_constant_central_force].
*/
static body_get_constant_force(body: RID): Vector3
/** Sets the body's total constant rotational forces applied during each physics update.
* See [method body_add_constant_torque].
*/
static body_set_constant_torque(body: RID, torque: Vector3): void
/** Returns the body's total constant rotational forces applied during each physics update.
* See [method body_add_constant_torque].
*/
static body_get_constant_torque(body: RID): Vector3
/** Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. */
static body_set_axis_velocity(body: RID, axis_velocity: Vector3): void
static body_set_axis_lock(body: RID, axis: PhysicsServer3D.BodyAxis, lock: boolean): void
static body_is_axis_locked(body: RID, axis: PhysicsServer3D.BodyAxis): boolean
/** Adds a body to the list of bodies exempt from collisions. */
static body_add_collision_exception(body: RID, excepted_body: RID): void
/** Removes a body from the list of bodies exempt from collisions.
* Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
*/
static body_remove_collision_exception(body: RID, excepted_body: RID): void
/** Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies. This is enabled by setting the maximum number of contacts reported to a number greater than 0. */
static body_set_max_contacts_reported(body: RID, amount: int64): void
/** Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported]. */
static body_get_max_contacts_reported(body: RID): int64
/** Sets whether the body omits the standard force integration. If [param enable] is `true`, the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, [method body_set_force_integration_callback] can be used to manually update the linear and angular velocity instead.
* This method is called when the property [member RigidBody3D.custom_integrator] is set.
*/
static body_set_omit_force_integration(body: RID, enable: boolean): void
/** Returns `true` if the body is omitting the standard force integration. See [method body_set_omit_force_integration]. */
static body_is_omitting_force_integration(body: RID): boolean
/** Sets the body's state synchronization callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()`) to clear the callback.
* The function [param callable] will be called every physics frame, assuming that the body was active during the previous physics tick, and can be used to fetch the latest state from the physics server.
* The function [param callable] must take the following parameters:
* 1. `state`: a [PhysicsDirectBodyState3D], used to retrieve the body's state.
*/
static body_set_state_sync_callback(body: RID, callable: Callable): void
/** Sets the body's custom force integration callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()`) to clear the custom callback.
* The function [param callable] will be called every physics tick, before the standard force integration (see [method body_set_omit_force_integration]). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
* If [param userdata] is not `null`, the function [param callable] must take the following two parameters:
* 1. `state`: a [PhysicsDirectBodyState3D], used to retrieve and modify the body's state,
* 2. [code skip-lint]userdata`: a [Variant]; its value will be the [param userdata] passed into this method.
* If [param userdata] is `null`, then [param callable] must take only the `state` parameter.
*/
static body_set_force_integration_callback(body: RID, callable: Callable, userdata: any = {}): void
/** Sets the body pickable with rays if [param enable] is set. */
static body_set_ray_pickable(body: RID, enable: boolean): void
/** Returns `true` if a collision would result from moving along a motion vector from a given point in space. [PhysicsTestMotionParameters3D] is passed to set motion parameters. [PhysicsTestMotionResult3D] can be passed to return additional information. */
static body_test_motion(body: RID, parameters: PhysicsTestMotionParameters3D, result: PhysicsTestMotionResult3D = undefined): boolean
/** Returns the [PhysicsDirectBodyState3D] of the body. Returns `null` if the body is destroyed or removed from the physics space. */
static body_get_direct_state(body: RID): PhysicsDirectBodyState3D
/** Creates a new soft body and returns its internal [RID]. */
static soft_body_create(): RID
/** Requests that the physics server updates the rendering server with the latest positions of the given soft body's points through the [param rendering_server_handler] interface. */
static soft_body_update_rendering_server(body: RID, rendering_server_handler: PhysicsServer3DRenderingServerHandler): void
/** Assigns a space to the given soft body (see [method space_create]). */
static soft_body_set_space(body: RID, space: RID): void
/** Returns the [RID] of the space assigned to the given soft body. */
static soft_body_get_space(body: RID): RID
/** Sets the mesh of the given soft body. */
static soft_body_set_mesh(body: RID, mesh: RID): void
/** Returns the bounds of the given soft body in global coordinates. */
static soft_body_get_bounds(body: RID): AABB
/** Sets the physics layer or layers the given soft body belongs to. */
static soft_body_set_collision_layer(body: RID, layer: int64): void
/** Returns the physics layer or layers that the given soft body belongs to. */
static soft_body_get_collision_layer(body: RID): int64
/** Sets the physics layer or layers the given soft body can collide with. */
static soft_body_set_collision_mask(body: RID, mask: int64): void
/** Returns the physics layer or layers that the given soft body can collide with. */
static soft_body_get_collision_mask(body: RID): int64
/** Adds the given body to the list of bodies exempt from collisions. */
static soft_body_add_collision_exception(body: RID, body_b: RID): void
/** Removes the given body from the list of bodies exempt from collisions. */
static soft_body_remove_collision_exception(body: RID, body_b: RID): void
/** Sets the given body state for the given body (see [enum BodyState] constants).
*
* **Note:** Godot's default physics implementation does not support [constant BODY_STATE_LINEAR_VELOCITY], [constant BODY_STATE_ANGULAR_VELOCITY], [constant BODY_STATE_SLEEPING], or [constant BODY_STATE_CAN_SLEEP].
*/
static soft_body_set_state(body: RID, state: PhysicsServer3D.BodyState, variant: any): void
/** Returns the given soft body state (see [enum BodyState] constants).
*
* **Note:** Godot's default physics implementation does not support [constant BODY_STATE_LINEAR_VELOCITY], [constant BODY_STATE_ANGULAR_VELOCITY], [constant BODY_STATE_SLEEPING], or [constant BODY_STATE_CAN_SLEEP].
*/
static soft_body_get_state(body: RID, state: PhysicsServer3D.BodyState): any
/** Sets the global transform of the given soft body. */
static soft_body_set_transform(body: RID, transform: Transform3D): void
/** Sets whether the given soft body will be pickable when using object picking. */
static soft_body_set_ray_pickable(body: RID, enable: boolean): void
/** Sets the simulation precision of the given soft body. Increasing this value will improve the resulting simulation, but can affect performance. Use with care. */
static soft_body_set_simulation_precision(body: RID, simulation_precision: int64): void
/** Returns the simulation precision of the given soft body. */
static soft_body_get_simulation_precision(body: RID): int64
/** Sets the total mass for the given soft body. */
static soft_body_set_total_mass(body: RID, total_mass: float64): void
/** Returns the total mass assigned to the given soft body. */
static soft_body_get_total_mass(body: RID): float64
/** Sets the linear stiffness of the given soft body. Higher values will result in a stiffer body, while lower values will increase the body's ability to bend. The value can be between `0.0` and `1.0` (inclusive). */
static soft_body_set_linear_stiffness(body: RID, stiffness: float64): void
/** Returns the linear stiffness of the given soft body. */
static soft_body_get_linear_stiffness(body: RID): float64
/** Sets the pressure coefficient of the given soft body. Simulates pressure build-up from inside this body. Higher values increase the strength of this effect. */
static soft_body_set_pressure_coefficient(body: RID, pressure_coefficient: float64): void
/** Returns the pressure coefficient of the given soft body. */
static soft_body_get_pressure_coefficient(body: RID): float64
/** Sets the damping coefficient of the given soft body. Higher values will slow down the body more noticeably when forces are applied. */
static soft_body_set_damping_coefficient(body: RID, damping_coefficient: float64): void
/** Returns the damping coefficient of the given soft body. */
static soft_body_get_damping_coefficient(body: RID): float64
/** Sets the drag coefficient of the given soft body. Higher values increase this body's air resistance.
*
* **Note:** This value is currently unused by Godot's default physics implementation.
*/
static soft_body_set_drag_coefficient(body: RID, drag_coefficient: float64): void
/** Returns the drag coefficient of the given soft body. */
static soft_body_get_drag_coefficient(body: RID): float64
/** Moves the given soft body point to a position in global coordinates. */
static soft_body_move_point(body: RID, point_index: int64, global_position: Vector3): void
/** Returns the current position of the given soft body point in global coordinates. */
static soft_body_get_point_global_position(body: RID, point_index: int64): Vector3
/** Unpins all points of the given soft body. */
static soft_body_remove_all_pinned_points(body: RID): void
/** Pins or unpins the given soft body point based on the value of [param pin].
*
* **Note:** Pinning a point effectively makes it kinematic, preventing it from being affected by forces, but you can still move it using [method soft_body_move_point].
*/
static soft_body_pin_point(body: RID, point_index: int64, pin: boolean): void
/** Returns whether the given soft body point is pinned. */
static soft_body_is_point_pinned(body: RID, point_index: int64): boolean
static joint_create(): RID
static joint_clear(joint: RID): void
static joint_make_pin(joint: RID, body_A: RID, local_A: Vector3, body_B: RID, local_B: Vector3): void
/** Sets a pin_joint parameter (see [enum PinJointParam] constants). */
static pin_joint_set_param(joint: RID, param: PhysicsServer3D.PinJointParam, value: float64): void
/** Gets a pin_joint parameter (see [enum PinJointParam] constants). */
static pin_joint_get_param(joint: RID, param: PhysicsServer3D.PinJointParam): float64
/** Sets position of the joint in the local space of body a of the joint. */
static pin_joint_set_local_a(joint: RID, local_A: Vector3): void
/** Returns position of the joint in the local space of body a of the joint. */
static pin_joint_get_local_a(joint: RID): Vector3
/** Sets position of the joint in the local space of body b of the joint. */
static pin_joint_set_local_b(joint: RID, local_B: Vector3): void
/** Returns position of the joint in the local space of body b of the joint. */
static pin_joint_get_local_b(joint: RID): Vector3
static joint_make_hinge(joint: RID, body_A: RID, hinge_A: Transform3D, body_B: RID, hinge_B: Transform3D): void
/** Sets a hinge_joint parameter (see [enum HingeJointParam] constants). */
static hinge_joint_set_param(joint: RID, param: PhysicsServer3D.HingeJointParam, value: float64): void
/** Gets a hinge_joint parameter (see [enum HingeJointParam]). */
static hinge_joint_get_param(joint: RID, param: PhysicsServer3D.HingeJointParam): float64
/** Sets a hinge_joint flag (see [enum HingeJointFlag] constants). */
static hinge_joint_set_flag(joint: RID, flag: PhysicsServer3D.HingeJointFlag, enabled: boolean): void
/** Gets a hinge_joint flag (see [enum HingeJointFlag] constants). */
static hinge_joint_get_flag(joint: RID, flag: PhysicsServer3D.HingeJointFlag): boolean
static joint_make_slider(joint: RID, body_A: RID, local_ref_A: Transform3D, body_B: RID, local_ref_B: Transform3D): void
/** Gets a slider_joint parameter (see [enum SliderJointParam] constants). */
static slider_joint_set_param(joint: RID, param: PhysicsServer3D.SliderJointParam, value: float64): void
/** Gets a slider_joint parameter (see [enum SliderJointParam] constants). */
static slider_joint_get_param(joint: RID, param: PhysicsServer3D.SliderJointParam): float64
static joint_make_cone_twist(joint: RID, body_A: RID, local_ref_A: Transform3D, body_B: RID, local_ref_B: Transform3D): void
/** Sets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants). */
static cone_twist_joint_set_param(joint: RID, param: PhysicsServer3D.ConeTwistJointParam, value: float64): void
/** Gets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants). */
static cone_twist_joint_get_param(joint: RID, param: PhysicsServer3D.ConeTwistJointParam): float64
/** Returns the type of the Joint3D. */
static joint_get_type(joint: RID): PhysicsServer3D.JointType
/** Sets the priority value of the Joint3D. */
static joint_set_solver_priority(joint: RID, priority: int64): void
/** Gets the priority value of the Joint3D. */
static joint_get_solver_priority(joint: RID): int64
/** Sets whether the bodies attached to the [Joint3D] will collide with each other. */
static joint_disable_collisions_between_bodies(joint: RID, disable: boolean): void
/** Returns whether the bodies attached to the [Joint3D] will collide with each other. */
static joint_is_disabled_collisions_between_bodies(joint: RID): boolean
/** Make the joint a generic six degrees of freedom (6DOF) joint. Use [method generic_6dof_joint_set_flag] and [method generic_6dof_joint_set_param] to set the joint's flags and parameters respectively. */
static joint_make_generic_6dof(joint: RID, body_A: RID, local_ref_A: Transform3D, body_B: RID, local_ref_B: Transform3D): void
/** Sets the value of a given generic 6DOF joint parameter. See [enum G6DOFJointAxisParam] for the list of available parameters. */
static generic_6dof_joint_set_param(joint: RID, axis: Vector3.Axis, param: PhysicsServer3D.G6DOFJointAxisParam, value: float64): void
/** Returns the value of a generic 6DOF joint parameter. See [enum G6DOFJointAxisParam] for the list of available parameters. */
static generic_6dof_joint_get_param(joint: RID, axis: Vector3.Axis, param: PhysicsServer3D.G6DOFJointAxisParam): float64
/** Sets the value of a given generic 6DOF joint flag. See [enum G6DOFJointAxisFlag] for the list of available flags. */
static generic_6dof_joint_set_flag(joint: RID, axis: Vector3.Axis, flag: PhysicsServer3D.G6DOFJointAxisFlag, enable: boolean): void
/** Returns the value of a generic 6DOF joint flag. See [enum G6DOFJointAxisFlag] for the list of available flags. */
static generic_6dof_joint_get_flag(joint: RID, axis: Vector3.Axis, flag: PhysicsServer3D.G6DOFJointAxisFlag): boolean
/** Destroys any of the objects created by PhysicsServer3D. If the [RID] passed is not one of the objects that can be created by PhysicsServer3D, an error will be sent to the console. */
static free_rid(rid: RID): void
/** Activates or deactivates the 3D physics engine. */
static set_active(active: boolean): void
/** Returns information about the current state of the 3D physics engine. See [enum ProcessInfo] for a list of available states. */
static get_process_info(process_info: PhysicsServer3D.ProcessInfo): int64
}
// _singleton_class_: XRServer
namespace XRServer {
enum TrackerType {
/** The tracker tracks the location of the players head. This is usually a location centered between the players eyes. Note that for handheld AR devices this can be the current location of the device. */
TRACKER_HEAD = 1,
/** The tracker tracks the location of a controller. */
TRACKER_CONTROLLER = 2,
/** The tracker tracks the location of a base station. */
TRACKER_BASESTATION = 4,
/** The tracker tracks the location and size of an AR anchor. */
TRACKER_ANCHOR = 8,
/** The tracker tracks the location and joints of a hand. */
TRACKER_HAND = 16,
/** The tracker tracks the location and joints of a body. */
TRACKER_BODY = 32,
/** The tracker tracks the expressions of a face. */
TRACKER_FACE = 64,
/** Used internally to filter trackers of any known type. */
TRACKER_ANY_KNOWN = 127,
/** Used internally if we haven't set the tracker type yet. */
TRACKER_UNKNOWN = 128,
/** Used internally to select all trackers. */
TRACKER_ANY = 255,
}
enum RotationMode {
/** Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world. */
RESET_FULL_ROTATION = 0,
/** Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset. */
RESET_BUT_KEEP_TILT = 1,
/** Does not reset the orientation of the HMD, only the position of the player gets centered. */
DONT_RESET_ROTATION = 2,
}
}
/** Server for AR and VR features.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_xrserver.html
*/
class XRServer extends Object {
/** Returns the reference frame transform. Mostly used internally and exposed for GDExtension build interfaces. */
static get_reference_frame(): Transform3D
/** Clears the reference frame that was set by previous calls to [method center_on_hmd]. */
static clear_reference_frame(): void
/** This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
* For platforms that do not offer spatial tracking, our origin point (0, 0, 0) is the location of our HMD, but you have little control over the direction the player is facing in the real world.
* For platforms that do offer spatial tracking, our origin point depends very much on the system. For OpenVR, our origin point is usually the center of the tracking space, on the ground. For other platforms, it's often the location of the tracking camera.
* This method allows you to center your tracker on the location of the HMD. It will take the current location of the HMD and use that to adjust all your tracking data; in essence, realigning the real world to your player's current position in the game world.
* For this method to produce usable results, tracking information must be available. This often takes a few frames after starting your game.
* You should call this method after a few seconds have passed. For example, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
*/
static center_on_hmd(rotation_mode: XRServer.RotationMode, keep_height: boolean): void
/** Returns the primary interface's transformation. */
static get_hmd_transform(): Transform3D
/** Registers an [XRInterface] object. */
static add_interface(interface: XRInterface): void
/** Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns `true`. */
static get_interface_count(): int64
/** Removes this [param interface]. */
static remove_interface(interface: XRInterface): void
/** Returns the interface registered at the given [param idx] index in the list of interfaces. */
static get_interface(idx: int64): XRInterface
/** Returns a list of available interfaces the ID and name of each interface. */
static get_interfaces(): GArray
/** Finds an interface by its [param name]. For example, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it. */
static find_interface(name: string): XRInterface
/** Registers a new [XRTracker] that tracks a physical object. */
static add_tracker(tracker: XRTracker): void
/** Removes this [param tracker]. */
static remove_tracker(tracker: XRTracker): void
/** Returns a dictionary of trackers for [param tracker_types]. */
static get_trackers(tracker_types: int64): GDictionary
/** Returns the positional tracker with the given [param tracker_name]. */
static get_tracker(tracker_name: StringName): XRTracker
/** The scale of the game world compared to the real world. By default, most AR/VR platforms assume that 1 game unit corresponds to 1 real world meter. */
get world_scale(): float64
set world_scale(value: float64)
/** The current origin of our tracking space in the virtual world. This is used by the renderer to properly position the camera with new tracking data.
*
* **Note:** This property is managed by the current [XROrigin3D] node. It is exposed for access from GDExtensions.
*/
get world_origin(): Vector3
set world_origin(value: Vector3)
/** If set to `true`, the scene will be rendered as if the camera is locked to the [XROrigin3D].
*
* **Note:** This doesn't provide a very comfortable experience for users. This setting exists for doing benchmarking or automated testing, where you want to control what is rendered via code.
*/
get camera_locked_to_origin(): boolean
set camera_locked_to_origin(value: boolean)
/** The primary [XRInterface] currently bound to the [XRServer]. */
get primary_interface(): Object
set primary_interface(value: Object)
/** Emitted when the reference frame transform changes. */
static readonly reference_frame_changed: Signal0
/** Emitted when a new interface has been added. */
static readonly interface_added: Signal1
/** Emitted when an interface is removed. */
static readonly interface_removed: Signal1
/** Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using [XRAnchor3D]s for an AR solution, it is important to react to this signal to add the appropriate [XRController3D] or [XRAnchor3D] nodes related to this new tracker. */
static readonly tracker_added: Signal2
/** Emitted when an existing tracker has been updated. This can happen if the user switches controllers. */
static readonly tracker_updated: Signal2
/** Emitted when a tracker is removed. You should remove any [XRController3D] or [XRAnchor3D] points if applicable. This is not mandatory, the nodes simply become inactive and will be made active again when a new tracker becomes available (i.e. a new controller is switched on that takes the place of the previous one). */
static readonly tracker_removed: Signal2
}
// _singleton_class_: GDScriptLanguageProtocol
/** @link https://docs.godotengine.org/en/4.4/classes/class_gdscriptlanguageprotocol.html */
class GDScriptLanguageProtocol extends JSONRPC {
static initialize(params: GDictionary): GDictionary
static initialized(params: any): void
static on_client_connected(): GError
static on_client_disconnected(_unnamed_arg0: int64): void
static notify_client(method: string, params: any = {}, client_id: int64 = -1): void
static is_smart_resolve_enabled(): boolean
static get_text_document(): GDScriptTextDocument
static get_workspace(): GDScriptWorkspace
static is_initialized(): boolean
}
namespace AESContext {
enum Mode {
/** AES electronic codebook encryption mode. */
MODE_ECB_ENCRYPT = 0,
/** AES electronic codebook decryption mode. */
MODE_ECB_DECRYPT = 1,
/** AES cipher blocker chaining encryption mode. */
MODE_CBC_ENCRYPT = 2,
/** AES cipher blocker chaining decryption mode. */
MODE_CBC_DECRYPT = 3,
/** Maximum value for the mode enum. */
MODE_MAX = 4,
}
}
/** Provides access to AES encryption/decryption of raw data.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_aescontext.html
*/
class AESContext extends RefCounted {
constructor(identifier?: any)
/** Start the AES context in the given [param mode]. A [param key] of either 16 or 32 bytes must always be provided, while an [param iv] (initialization vector) of exactly 16 bytes, is only needed when [param mode] is either [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT]. */
start(mode: AESContext.Mode, key: PackedByteArray | byte[] | ArrayBuffer, iv: PackedByteArray | byte[] | ArrayBuffer = []): GError
/** Run the desired operation for this AES context. Will return a [PackedByteArray] containing the result of encrypting (or decrypting) the given [param src]. See [method start] for mode of operation.
*
* **Note:** The size of [param src] must be a multiple of 16. Apply some padding if needed.
*/
update(src: PackedByteArray | byte[] | ArrayBuffer): PackedByteArray
/** Get the current IV state for this context (IV gets updated when calling [method update]). You normally don't need this function.
*
* **Note:** This function only makes sense when the context is started with [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT].
*/
get_iv_state(): PackedByteArray
/** Close this AES context so it can be started again. See [method start]. */
finish(): void
}
/** An implementation of A* for finding the shortest path between two vertices on a connected graph in 2D space.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_astar2d.html
*/
class AStar2D extends RefCounted {
constructor(identifier?: any)
/** Called when estimating the cost between a point and the path's ending point.
* Note that this function is hidden in the default [AStar2D] class.
*/
/* gdvirtual */ _estimate_cost(from_id: int64, end_id: int64): float64
/** Called when computing the cost between two connected points.
* Note that this function is hidden in the default [AStar2D] class.
*/
/* gdvirtual */ _compute_cost(from_id: int64, to_id: int64): float64
/** Returns the next available point ID with no point associated to it. */
get_available_point_id(): int64
/** Adds a new point at the given position with the given identifier. The [param id] must be 0 or larger, and the [param weight_scale] must be 0.0 or greater.
* The [param weight_scale] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [param weight_scale]s to form a path.
*
* If there already exists a point for the given [param id], its position and weight scale are updated to the given values.
*/
add_point(id: int64, position: Vector2, weight_scale: float64 = 1): void
/** Returns the position of the point associated with the given [param id]. */
get_point_position(id: int64): Vector2
/** Sets the [param position] for the point with the given [param id]. */
set_point_position(id: int64, position: Vector2): void
/** Returns the weight scale of the point associated with the given [param id]. */
get_point_weight_scale(id: int64): float64
/** Sets the [param weight_scale] for the point with the given [param id]. The [param weight_scale] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. */
set_point_weight_scale(id: int64, weight_scale: float64): void
/** Removes the point associated with the given [param id] from the points pool. */
remove_point(id: int64): void
/** Returns whether a point associated with the given [param id] exists. */
has_point(id: int64): boolean
/** Returns an array with the IDs of the points that form the connection with the given point.
*
*/
get_point_connections(id: int64): PackedInt64Array
/** Returns an array of all point IDs. */
get_point_ids(): PackedInt64Array
/** Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle. */
set_point_disabled(id: int64, disabled: boolean = true): void
/** Returns whether a point is disabled or not for pathfinding. By default, all points are enabled. */
is_point_disabled(id: int64): boolean
/** Creates a segment between the given points. If [param bidirectional] is `false`, only movement from [param id] to [param to_id] is allowed, not the reverse direction.
*
*/
connect_points(id: int64, to_id: int64, bidirectional: boolean = true): void
/** Deletes the segment between the given points. If [param bidirectional] is `false`, only movement from [param id] to [param to_id] is prevented, and a unidirectional segment possibly remains. */
disconnect_points(id: int64, to_id: int64, bidirectional: boolean = true): void
/** Returns whether there is a connection/segment between the given points. If [param bidirectional] is `false`, returns whether movement from [param id] to [param to_id] is possible through this segment. */
are_points_connected(id: int64, to_id: int64, bidirectional: boolean = true): boolean
/** Returns the number of points currently in the points pool. */
get_point_count(): int64
/** Returns the capacity of the structure backing the points, useful in conjunction with [method reserve_space]. */
get_point_capacity(): int64
/** Reserves space internally for [param num_nodes] points. Useful if you're adding a known large number of points at once, such as points on a grid. The new capacity must be greater or equal to the old capacity. */
reserve_space(num_nodes: int64): void
/** Clears all the points and segments. */
clear(): void
/** Returns the ID of the closest point to [param to_position], optionally taking disabled points into account. Returns `-1` if there are no points in the points pool.
*
* **Note:** If several points are the closest to [param to_position], the one with the smallest ID will be returned, ensuring a deterministic result.
*/
get_closest_point(to_position: Vector2, include_disabled: boolean = false): int64
/** Returns the closest position to [param to_position] that resides inside a segment between two connected points.
*
* The result is in the segment that goes from `y = 0` to `y = 5`. It's the closest position in the segment to the given point.
*/
get_closest_position_in_segment(to_position: Vector2): Vector2
/** Returns an array with the points that are in the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.
* If there is no valid path to the target, and [param allow_partial_path] is `true`, returns a path to the point closest to the target that can be reached.
*
* **Note:** This method is not thread-safe. If called from a [Thread], it will return an empty array and will print an error message.
* Additionally, when [param allow_partial_path] is `true` and [param to_id] is disabled the search may take an unusually long time to finish.
*/
get_point_path(from_id: int64, to_id: int64, allow_partial_path: boolean = false): PackedVector2Array
/** Returns an array with the IDs of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.
* If there is no valid path to the target, and [param allow_partial_path] is `true`, returns a path to the point closest to the target that can be reached.
*
* **Note:** When [param allow_partial_path] is `true` and [param to_id] is disabled the search may take an unusually long time to finish.
*
* If you change the 2nd point's weight to 3, then the result will be `[1, 4, 3]` instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2.
*/
get_id_path(from_id: int64, to_id: int64, allow_partial_path: boolean = false): PackedInt64Array
}
/** An implementation of A* for finding the shortest path between two vertices on a connected graph in 3D space.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_astar3d.html
*/
class AStar3D extends RefCounted {
constructor(identifier?: any)
/** Called when estimating the cost between a point and the path's ending point.
* Note that this function is hidden in the default [AStar3D] class.
*/
/* gdvirtual */ _estimate_cost(from_id: int64, end_id: int64): float64
/** Called when computing the cost between two connected points.
* Note that this function is hidden in the default [AStar3D] class.
*/
/* gdvirtual */ _compute_cost(from_id: int64, to_id: int64): float64
/** Returns the next available point ID with no point associated to it. */
get_available_point_id(): int64
/** Adds a new point at the given position with the given identifier. The [param id] must be 0 or larger, and the [param weight_scale] must be 0.0 or greater.
* The [param weight_scale] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [param weight_scale]s to form a path.
*
* If there already exists a point for the given [param id], its position and weight scale are updated to the given values.
*/
add_point(id: int64, position: Vector3, weight_scale: float64 = 1): void
/** Returns the position of the point associated with the given [param id]. */
get_point_position(id: int64): Vector3
/** Sets the [param position] for the point with the given [param id]. */
set_point_position(id: int64, position: Vector3): void
/** Returns the weight scale of the point associated with the given [param id]. */
get_point_weight_scale(id: int64): float64
/** Sets the [param weight_scale] for the point with the given [param id]. The [param weight_scale] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. */
set_point_weight_scale(id: int64, weight_scale: float64): void
/** Removes the point associated with the given [param id] from the points pool. */
remove_point(id: int64): void
/** Returns whether a point associated with the given [param id] exists. */
has_point(id: int64): boolean
/** Returns an array with the IDs of the points that form the connection with the given point.
*
*/
get_point_connections(id: int64): PackedInt64Array
/** Returns an array of all point IDs. */
get_point_ids(): PackedInt64Array
/** Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle. */
set_point_disabled(id: int64, disabled: boolean = true): void
/** Returns whether a point is disabled or not for pathfinding. By default, all points are enabled. */
is_point_disabled(id: int64): boolean
/** Creates a segment between the given points. If [param bidirectional] is `false`, only movement from [param id] to [param to_id] is allowed, not the reverse direction.
*
*/
connect_points(id: int64, to_id: int64, bidirectional: boolean = true): void
/** Deletes the segment between the given points. If [param bidirectional] is `false`, only movement from [param id] to [param to_id] is prevented, and a unidirectional segment possibly remains. */
disconnect_points(id: int64, to_id: int64, bidirectional: boolean = true): void
/** Returns whether the two given points are directly connected by a segment. If [param bidirectional] is `false`, returns whether movement from [param id] to [param to_id] is possible through this segment. */
are_points_connected(id: int64, to_id: int64, bidirectional: boolean = true): boolean
/** Returns the number of points currently in the points pool. */
get_point_count(): int64
/** Returns the capacity of the structure backing the points, useful in conjunction with [method reserve_space]. */
get_point_capacity(): int64
/** Reserves space internally for [param num_nodes] points. Useful if you're adding a known large number of points at once, such as points on a grid. New capacity must be greater or equals to old capacity. */
reserve_space(num_nodes: int64): void
/** Clears all the points and segments. */
clear(): void
/** Returns the ID of the closest point to [param to_position], optionally taking disabled points into account. Returns `-1` if there are no points in the points pool.
*
* **Note:** If several points are the closest to [param to_position], the one with the smallest ID will be returned, ensuring a deterministic result.
*/
get_closest_point(to_position: Vector3, include_disabled: boolean = false): int64
/** Returns the closest position to [param to_position] that resides inside a segment between two connected points.
*
* The result is in the segment that goes from `y = 0` to `y = 5`. It's the closest position in the segment to the given point.
*/
get_closest_position_in_segment(to_position: Vector3): Vector3
/** Returns an array with the points that are in the path found by AStar3D between the given points. The array is ordered from the starting point to the ending point of the path.
* If there is no valid path to the target, and [param allow_partial_path] is `true`, returns a path to the point closest to the target that can be reached.
*
* **Note:** This method is not thread-safe. If called from a [Thread], it will return an empty array and will print an error message.
* Additionally, when [param allow_partial_path] is `true` and [param to_id] is disabled the search may take an unusually long time to finish.
*/
get_point_path(from_id: int64, to_id: int64, allow_partial_path: boolean = false): PackedVector3Array
/** Returns an array with the IDs of the points that form the path found by AStar3D between the given points. The array is ordered from the starting point to the ending point of the path.
* If there is no valid path to the target, and [param allow_partial_path] is `true`, returns a path to the point closest to the target that can be reached.
*
* **Note:** When [param allow_partial_path] is `true` and [param to_id] is disabled the search may take an unusually long time to finish.
*
* If you change the 2nd point's weight to 3, then the result will be `[1, 4, 3]` instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2.
*/
get_id_path(from_id: int64, to_id: int64, allow_partial_path: boolean = false): PackedInt64Array
}
namespace AStarGrid2D {
enum Heuristic {
/** The [url=https://en.wikipedia.org/wiki/Euclidean_distance]Euclidean heuristic[/url] to be used for the pathfinding using the following formula:
*
*
* **Note:** This is also the internal heuristic used in [AStar3D] and [AStar2D] by default (with the inclusion of possible z-axis coordinate).
*/
HEURISTIC_EUCLIDEAN = 0,
/** The [url=https://en.wikipedia.org/wiki/Taxicab_geometry]Manhattan heuristic[/url] to be used for the pathfinding using the following formula:
*
*
* **Note:** This heuristic is intended to be used with 4-side orthogonal movements, provided by setting the [member diagonal_mode] to [constant DIAGONAL_MODE_NEVER].
*/
HEURISTIC_MANHATTAN = 1,
/** The Octile heuristic to be used for the pathfinding using the following formula:
*
*/
HEURISTIC_OCTILE = 2,
/** The [url=https://en.wikipedia.org/wiki/Chebyshev_distance]Chebyshev heuristic[/url] to be used for the pathfinding using the following formula:
*
*/
HEURISTIC_CHEBYSHEV = 3,
/** Represents the size of the [enum Heuristic] enum. */
HEURISTIC_MAX = 4,
}
enum DiagonalMode {
/** The pathfinding algorithm will ignore solid neighbors around the target cell and allow passing using diagonals. */
DIAGONAL_MODE_ALWAYS = 0,
/** The pathfinding algorithm will ignore all diagonals and the way will be always orthogonal. */
DIAGONAL_MODE_NEVER = 1,
/** The pathfinding algorithm will avoid using diagonals if at least two obstacles have been placed around the neighboring cells of the specific path segment. */
DIAGONAL_MODE_AT_LEAST_ONE_WALKABLE = 2,
/** The pathfinding algorithm will avoid using diagonals if any obstacle has been placed around the neighboring cells of the specific path segment. */
DIAGONAL_MODE_ONLY_IF_NO_OBSTACLES = 3,
/** Represents the size of the [enum DiagonalMode] enum. */
DIAGONAL_MODE_MAX = 4,
}
enum CellShape {
/** Rectangular cell shape. */
CELL_SHAPE_SQUARE = 0,
/** Diamond cell shape (for isometric look). Cell coordinates layout where the horizontal axis goes up-right, and the vertical one goes down-right. */
CELL_SHAPE_ISOMETRIC_RIGHT = 1,
/** Diamond cell shape (for isometric look). Cell coordinates layout where the horizontal axis goes down-right, and the vertical one goes down-left. */
CELL_SHAPE_ISOMETRIC_DOWN = 2,
/** Represents the size of the [enum CellShape] enum. */
CELL_SHAPE_MAX = 3,
}
}
/** An implementation of A* for finding the shortest path between two points on a partial 2D grid.
*
* @link https://docs.godotengine.org/en/4.4/classes/class_astargrid2d.html
*/
class AStarGrid2D extends RefCounted {
constructor(identifier?: any)
/** Called when estimating the cost between a point and the path's ending point.
* Note that this function is hidden in the default [AStarGrid2D] class.
*/
/* gdvirtual */ _estimate_cost(from_id: Vector2i, end_id: Vector2i): float64
/** Called when computing the cost between two connected points.
* Note that this function is hidden in the default [AStarGrid2D] class.
*/
/* gdvirtual */ _compute_cost(from_id: Vector2i, to_id: Vector2i): float64
/** Returns `true` if the [param x] and [param y] is a valid grid coordinate (id), i.e. if it is inside [member region]. Equivalent to `region.has_point(Vector2i(x, y))`. */
is_in_bounds(x: int64, y: int64): boolean
/** Returns `true` if the [param id] vector is a valid grid coordinate, i.e. if it is inside [member region]. Equivalent to `region.has_point(id)`. */
is_in_boundsv(id: Vector2i): boolean
/** Indicates that the grid parameters were changed and [method update] needs to be called. */
is_dirty(): boolean
/** Updates the internal state of the grid according to the parameters to prepare it to search the path. Needs to be called if parameters like [member region], [member cell_size] or [member offset] are changed. [method is_dirty] will return `true` if this is the case and this needs to be called.
*
* **Note:** All point data (solidity and weight scale) will be cleared.
*/
update(): void
/** Disables or enables the specified point for pathfinding. Useful for making an obstacle. By default, all points are enabled.
*
* **Note:** Calling [method update] is not needed after the call of this function.
*/
set_point_solid(id: Vector2i, solid: boolean = true): void
/** Returns `true` if a point is disabled for pathfinding. By default, all points are enabled. */
is_point_solid(id: Vector2i): boolean
/** Sets the [param weight_scale] for the point with the given [param id]. The [param weight_scale] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point.
*
* **Note:** Calling [method update] is not needed after the call of this function.
*/
set_point_weight_scale(id: Vector2i, weight_scale: float64): void
/** Returns the weight scale of the point associated with the given [param id]. */
get_point_weight_scale(id: Vector2i): float64
/** Fills the given [param region] on the grid with the specified value for the solid flag.
*
* **Note:** Calling [method update] is not needed after the call of this function.
*/
fill_solid_region(region: Rect2i, solid: boolean = true): void
/** Fills the given [param region] on the grid with the specified value for the weight scale.
*
* **Note:** Calling [method update] is not needed after the call of this function.
*/
fill_weight_scale_region(region: Rect2i, weight_scale: float64): void
/** Clears the grid and sets the [member region] to `Rect2i(0, 0, 0, 0)`. */
clear(): void
/** Returns the position of the point associated with the given [param id]. */
get_point_position(id: Vector2i): Vector2
/** Returns an array of dictionaries with point data (`id`: [Vector2i], `position`: [Vector2], `solid`: [bool], `weight_scale`: [float]) within a [param region]. */
get_point_data_in_region(region: Rect2i): GArray
/** Returns an array with the points that are in the path found by [AStarGrid2D] between the given points. The array is ordered from the starting point to the ending point of the path.
* If there is no valid path to the target, and [param allow_partial_path] is `true`, returns a path to the point closest to the target that can be reached.
*
* **Note:** This method is not thread-safe. If called from a [Thread], it will return an empty array and will print an error message.
* Additionally, when [param allow_partial_path] is `true` and [param to_id] is solid the search may take an unusually long time to finish.
*/
get_point_path(from_id: Vector2i, to_id: Vector2i, allow_partial_path: boolean = false): PackedVector2Array
/** Returns an array with the IDs of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.
* If there is no valid path to the target, and [param allow_partial_path] is `true`, returns a path to the point closest to the target that can be reached.
*
* **Note:** When [param allow_partial_path] is `true` and [param to_id] is solid the search may take an unusually long time to finish.
*/
get_id_path(from_id: Vector2i, to_id: Vector2i, allow_partial_path: boolean = false): GArray
/** The region of grid cells available for pathfinding. If changed, [method update] needs to be called before finding the next path. */
get region(): Rect2i
set region(value: Rect2i)
/** The size of the grid (number of cells of size [member cell_size] on each axis). If changed, [method update] needs to be called before finding the next path. */
get size(): Vector2i
set size(value: Vector2i)
/** The offset of the grid which will be applied to calculate the resulting point position returned by [method get_point_path]. If changed, [method update] needs to be called before finding the next path. */
get offset(): Vector2
set offset(value: Vector2)
/** The size of the point cell which will be applied to calculate the resulting point position returned by [method get_point_path]. If changed, [method update] needs to be called before finding the next path. */
get cell_size(): Vector2
set cell_size(value: Vector2)
/** The cell shape. Affects how the positions are placed in the grid. If changed, [method update] needs to be called before finding the next path. */
get cell_shape(): int64
set cell_shape(value: int64)
/** Enables or disables jumping to skip up the intermediate points and speeds up the searching algorithm.
*
* **Note:** Currently, toggling it on disables the consideration of weight scaling in pathfinding.
*/
get jumping_enabled(): boolean
set jumping_enabled(value: boolean)
/** The default [enum Heuristic] which will be used to calculate the cost between two points if [method _compute_cost] was not overridden. */
get default_compute_heuristic(): int64
set default_compute_heuristic(value: int64)
/** The default [enum Heuristic] which will be used to calculate the cost between the point and the end point if [method _estimate_cost] was not overridden. */
get default_estimate_heuristic(): int64
set default_estimate_heuristic(value: int64)
/** A specific [enum DiagonalMode] mode which will force the path to avoid or accept the specified diagonals. */
get diagonal_mode(): int64
set diagonal_mode(value: int64)
}
class AbstractPolygon2DEditor