PhysicsServer2D

package
v0.0.0-...-e1beaa7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

PhysicsServer2D is the server responsible for all 2D physics. It can directly create and manipulate all physics objects:

- A space is a self-contained world for a physics simulation. It contains bodies, areas, and joints. Its state can be queried for collision and intersection information, and several parameters of the simulation can be modified.

- A shape is a geometric shape such as a circle, a rectangle, a capsule, or a polygon. It can be used for collision detection by adding it to a body/area, possibly with an extra transformation relative to the body/area's origin. Bodies/areas can have multiple (transformed) shapes added to them, and a single shape can be added to bodies/areas multiple times with different local transformations.

- A body is a physical object which can be in static, kinematic, or rigid mode. Its state (such as position and velocity) can be queried and updated. A force integration callback can be set to customize the body's physics.

- An area is a region in space which can be used to detect bodies and areas entering and exiting it. A body monitoring callback can be set to report entering/exiting body shapes, and similarly an area monitoring callback can be set. Gravity and damping can be overridden within the area by setting area parameters.

- A joint is a constraint, either between two bodies or on one body relative to a point. Parameters such as the joint bias and the rest length of a spring joint can be adjusted.

Physics objects in graphics.gd/classdb/PhysicsServer2D may be created and manipulated independently; they do not have to be tied to nodes in the scene tree.

Note: All the 2D physics nodes use the physics server internally. Adding a physics node to the scene tree will cause a corresponding physics object to be created in the physics server. A rigid body node registers a callback that updates the node's transform with the transform of the respective body object in the physics server (every physics update). An area node registers a callback to inform the area node about overlaps with the respective area object in the physics server. The raycast node queries the direct state of the relevant space in the physics server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Advanced

func Advanced() class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

func AreaAddShape

func AreaAddShape(area RID.Area2D, shape RID.Shape2D, disabled bool)

Adds a shape to the area, with the given local transform. The shape (together with its 'transform' and 'disabled' properties) is added to an array of shapes, and the shapes of an area are usually referenced by their index in this array.

func AreaAddShapeOptions

func AreaAddShapeOptions(area RID.Area2D, shape RID.Shape2D, transform Transform2D.OriginXY, disabled bool)

Adds a shape to the area, with the given local transform. The shape (together with its 'transform' and 'disabled' properties) is added to an array of shapes, and the shapes of an area are usually referenced by their index in this array.

func AreaAttachCanvasInstanceId

func AreaAttachCanvasInstanceId(area RID.Area2D, id int)

Attaches the ObjectID of a canvas to the area. Use graphics.gd/classdb/Object.Instance.GetInstanceId to get the ObjectID of a graphics.gd/classdb/CanvasLayer.

func AreaAttachObjectInstanceId

func AreaAttachObjectInstanceId(area RID.Area2D, id int)

Attaches the ObjectID of an graphics.gd/classdb/Object to the area. Use graphics.gd/classdb/Object.Instance.GetInstanceId to get the ObjectID of a graphics.gd/classdb/CollisionObject2D.

func AreaClearShapes

func AreaClearShapes(area RID.Area2D)

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.

func AreaCreate

func AreaCreate() RID.Area2D

Creates a 2D area object in the physics server, and returns the [Resource.ID] 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 AreaAddShape to add shapes to it, use AreaSetTransform to set its transform, and use AreaSetSpace to add the area to a space. If you want the area to be detectable use AreaSetMonitorable.

func AreaGetCanvasInstanceId

func AreaGetCanvasInstanceId(area RID.Area2D) int

Returns the ObjectID of the canvas attached to the area. Use [graphics.gd/classdb/@GlobalScope.Instance.InstanceFromId] to retrieve a graphics.gd/classdb/CanvasLayer from a nonzero ObjectID.

func AreaGetCollisionLayer

func AreaGetCollisionLayer(area RID.Area2D) int

Returns the physics layer or layers the area belongs to, as a bitmask.

func AreaGetCollisionMask

func AreaGetCollisionMask(area RID.Area2D) int

Returns the physics layer or layers the area can contact with, as a bitmask.

func AreaGetObjectInstanceId

func AreaGetObjectInstanceId(area RID.Area2D) int

Returns the ObjectID attached to the area. Use [graphics.gd/classdb/@GlobalScope.Instance.InstanceFromId] to retrieve an graphics.gd/classdb/Object from a nonzero ObjectID.

func AreaGetParam

func AreaGetParam(area RID.Area2D, param AreaParameter) any

Returns the value of the given area parameter.

func AreaGetShape

func AreaGetShape(area RID.Area2D, shape_idx int) RID.Shape2D

Returns the [Resource.ID] of the shape with the given index in the area's array of shapes.

func AreaGetShapeCount

func AreaGetShapeCount(area RID.Area2D) int

Returns the number of shapes added to the area.

func AreaGetShapeTransform

func AreaGetShapeTransform(area RID.Area2D, shape_idx int) Transform2D.OriginXY

Returns the local transform matrix of the shape with the given index in the area's array of shapes.

func AreaGetSpace

func AreaGetSpace(area RID.Area2D) RID.Space2D

Returns the [Resource.ID] of the space assigned to the area. Returns an empty [Resource.ID] if no space is assigned.

func AreaGetTransform

func AreaGetTransform(area RID.Area2D) Transform2D.OriginXY

Returns the transform matrix of the area.

func AreaRemoveShape

func AreaRemoveShape(area RID.Area2D, shape_idx int)

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 'shape_idx' will have their index decreased by one.

func AreaSetAreaMonitorCallback

func AreaSetAreaMonitorCallback(area RID.Area2D, callback func(status int, body_rid RID.Any, instance_id Object.ID, body_shape_idx int, self_shape_idx int))

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 AreaBodyAdded or AreaBodyRemoved depending on whether the other area's shape entered or exited the area,

2. an [Resource.ID] area_rid: the [Resource.ID] 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.

func AreaSetCollisionLayer

func AreaSetCollisionLayer(area RID.Area2D, layer int)

Assigns the area to one or many physics layers, via a bitmask.

func AreaSetCollisionMask

func AreaSetCollisionMask(area RID.Area2D, mask int)

Sets which physics layers the area will monitor, via a bitmask.

func AreaSetMonitorCallback

func AreaSetMonitorCallback(area RID.Area2D, callback func(status int, body_rid RID.Any, instance_id Object.ID, body_shape_idx int, self_shape_idx int))

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 AreaBodyAdded or AreaBodyRemoved depending on whether the other body shape entered or exited the area,

2. an [Resource.ID] body_rid: the [Resource.ID] 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.

func AreaSetMonitorable

func AreaSetMonitorable(area RID.Area2D, monitorable bool)

Sets whether the area is monitorable or not. If 'monitorable' is true, the area monitoring callback of other areas will be called when this area enters or exits them.

func AreaSetParam

func AreaSetParam(area RID.Area2D, param AreaParameter, value any)

Sets the value of the given area parameter.

func AreaSetShape

func AreaSetShape(area RID.Area2D, shape_idx int, shape RID.Shape2D)

Replaces the area's shape at the given index by another shape, while not affecting the transform and disabled properties at the same index.

func AreaSetShapeDisabled

func AreaSetShapeDisabled(area RID.Area2D, shape_idx int, disabled bool)

Sets the disabled property of the area's shape with the given index. If 'disabled' is true, then the shape will not detect any other shapes entering or exiting it.

func AreaSetShapeTransform

func AreaSetShapeTransform(area RID.Area2D, shape_idx int, transform Transform2D.OriginXY)

Sets the local transform matrix of the area's shape with the given index.

func AreaSetSpace

func AreaSetSpace(area RID.Area2D, space RID.Space2D)

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()).

func AreaSetTransform

func AreaSetTransform(area RID.Area2D, transform Transform2D.OriginXY)

Sets the transform matrix of the area.

func BodyAddCollisionException

func BodyAddCollisionException(body RID.Body2D, excepted_body RID.Body2D)

Adds 'excepted_body' to the body's list of collision exceptions, so that collisions with it are ignored.

func BodyAddConstantCentralForce

func BodyAddConstantCentralForce(body RID.Body2D, force Vector2.XY)

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 BodyAddConstantForce at the body's center of mass.

func BodyAddConstantForce

func BodyAddConstantForce(body RID.Body2D, force Vector2.XY, position Vector2.XY)

Adds a constant positioned force to the body. The force can affect rotation if '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)).

'position' is the offset from the body origin in global coordinates.

func BodyAddConstantForceOptions

func BodyAddConstantForceOptions(body RID.Body2D, force Vector2.XY, position Vector2.XY)

Adds a constant positioned force to the body. The force can affect rotation if '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)).

'position' is the offset from the body origin in global coordinates.

func BodyAddConstantTorque

func BodyAddConstantTorque(body RID.Body2D, torque Float.X)

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).

func BodyAddShape

func BodyAddShape(body RID.Body2D, shape RID.Shape2D, disabled bool)

Adds a shape to the area, with the given local transform. The shape (together with its 'transform' and 'disabled' properties) is added to an array of shapes, and the shapes of a body are usually referenced by their index in this array.

func BodyAddShapeOptions

func BodyAddShapeOptions(body RID.Body2D, shape RID.Shape2D, transform Transform2D.OriginXY, disabled bool)

Adds a shape to the area, with the given local transform. The shape (together with its 'transform' and 'disabled' properties) is added to an array of shapes, and the shapes of a body are usually referenced by their index in this array.

func BodyApplyCentralForce

func BodyApplyCentralForce(body RID.Body2D, force Vector2.XY)

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 BodyApplyForce at the body's center of mass.

func BodyApplyCentralImpulse

func BodyApplyCentralImpulse(body RID.Body2D, impulse Vector2.XY)

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 BodyApplyImpulse at the body's center of mass.

func BodyApplyForce

func BodyApplyForce(body RID.Body2D, force Vector2.XY, position Vector2.XY)

Applies a positioned force to the body. The force can affect rotation if 'position' is different from the body's center of mass. A force is time dependent and meant to be applied every physics update.

'position' is the offset from the body origin in global coordinates.

func BodyApplyForceOptions

func BodyApplyForceOptions(body RID.Body2D, force Vector2.XY, position Vector2.XY)

Applies a positioned force to the body. The force can affect rotation if 'position' is different from the body's center of mass. A force is time dependent and meant to be applied every physics update.

'position' is the offset from the body origin in global coordinates.

func BodyApplyImpulse

func BodyApplyImpulse(body RID.Body2D, impulse Vector2.XY, position Vector2.XY)

Applies a positioned impulse to the body. The impulse can affect rotation if '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).

'position' is the offset from the body origin in global coordinates.

func BodyApplyImpulseOptions

func BodyApplyImpulseOptions(body RID.Body2D, impulse Vector2.XY, position Vector2.XY)

Applies a positioned impulse to the body. The impulse can affect rotation if '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).

'position' is the offset from the body origin in global coordinates.

func BodyApplyTorque

func BodyApplyTorque(body RID.Body2D, torque Float.X)

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.

func BodyApplyTorqueImpulse

func BodyApplyTorqueImpulse(body RID.Body2D, impulse Float.X)

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).

func BodyAttachCanvasInstanceId

func BodyAttachCanvasInstanceId(body RID.Body2D, id int)

Attaches the ObjectID of a canvas to the body. Use graphics.gd/classdb/Object.Instance.GetInstanceId to get the ObjectID of a graphics.gd/classdb/CanvasLayer.

func BodyAttachObjectInstanceId

func BodyAttachObjectInstanceId(body RID.Body2D, id int)

Attaches the ObjectID of an graphics.gd/classdb/Object to the body. Use graphics.gd/classdb/Object.Instance.GetInstanceId to get the ObjectID of a graphics.gd/classdb/CollisionObject2D.

func BodyClearShapes

func BodyClearShapes(body RID.Body2D)

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.

func BodyCreate

func BodyCreate() RID.Body2D

Creates a 2D body object in the physics server, and returns the [Resource.ID] that identifies it. The default settings for the created area include a collision layer and mask set to 1, and body mode set to BodyModeRigid.

Use BodyAddShape to add shapes to it, use BodySetState to set its transform, and use BodySetSpace to add the body to a space.

func BodyGetCanvasInstanceId

func BodyGetCanvasInstanceId(body RID.Body2D) int

Returns the ObjectID of the canvas attached to the body. Use [graphics.gd/classdb/@GlobalScope.Instance.InstanceFromId] to retrieve a graphics.gd/classdb/CanvasLayer from a nonzero ObjectID.

func BodyGetCollisionLayer

func BodyGetCollisionLayer(body RID.Body2D) int

Returns the physics layer or layers the body belongs to, as a bitmask.

func BodyGetCollisionMask

func BodyGetCollisionMask(body RID.Body2D) int

Returns the physics layer or layers the body can collide with, as a bitmask.

func BodyGetCollisionPriority

func BodyGetCollisionPriority(body RID.Body2D) Float.X

Returns the body's collision priority. This is used in the depenetration phase of BodyTestMotion. The higher the priority is, the lower the penetration into the body will be.

func BodyGetConstantForce

func BodyGetConstantForce(body RID.Body2D) Vector2.XY

Returns the body's total constant positional force applied during each physics update.

See BodyAddConstantForce and BodyAddConstantCentralForce.

func BodyGetConstantTorque

func BodyGetConstantTorque(body RID.Body2D) Float.X

Returns the body's total constant rotational force applied during each physics update.

See BodyAddConstantTorque.

func BodyGetDirectState

func BodyGetDirectState(body RID.Body2D) PhysicsDirectBodyState2D.Instance

Returns the graphics.gd/classdb/PhysicsDirectBodyState2D of the body. Returns null if the body is destroyed or not assigned to a space.

func BodyGetMaxContactsReported

func BodyGetMaxContactsReported(body RID.Body2D) int

Returns the maximum number of contacts that the body can report. See BodySetMaxContactsReported.

func BodyGetObjectInstanceId

func BodyGetObjectInstanceId(body RID.Body2D) int

Returns the ObjectID attached to the body. Use [graphics.gd/classdb/@GlobalScope.Instance.InstanceFromId] to retrieve an graphics.gd/classdb/Object from a nonzero ObjectID.

func BodyGetParam

func BodyGetParam(body RID.Body2D, param BodyParameter) any

Returns the value of the given body parameter.

func BodyGetShape

func BodyGetShape(body RID.Body2D, shape_idx int) RID.Shape2D

Returns the [Resource.ID] of the shape with the given index in the body's array of shapes.

func BodyGetShapeCount

func BodyGetShapeCount(body RID.Body2D) int

Returns the number of shapes added to the body.

func BodyGetShapeTransform

func BodyGetShapeTransform(body RID.Body2D, shape_idx int) Transform2D.OriginXY

Returns the local transform matrix of the shape with the given index in the area's array of shapes.

func BodyGetSpace

func BodyGetSpace(body RID.Body2D) RID.Space2D

Returns the [Resource.ID] of the space assigned to the body. Returns an empty [Resource.ID] if no space is assigned.

func BodyGetState

func BodyGetState(body RID.Body2D, state BodyState) any

Returns the value of the given state of the body.

func BodyIsOmittingForceIntegration

func BodyIsOmittingForceIntegration(body RID.Body2D) bool

Returns true if the body is omitting the standard force integration. See BodySetOmitForceIntegration.

func BodyRemoveCollisionException

func BodyRemoveCollisionException(body RID.Body2D, excepted_body RID.Body2D)

Removes 'excepted_body' from the body's list of collision exceptions, so that collisions with it are no longer ignored.

func BodyRemoveShape

func BodyRemoveShape(body RID.Body2D, shape_idx int)

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 'shape_idx' will have their index decreased by one.

func BodyResetMassProperties

func BodyResetMassProperties(body RID.Body2D)

Restores the default inertia and center of mass of the body based on its shapes. This undoes any custom values previously set using BodySetParam.

func BodySetAxisVelocity

func BodySetAxisVelocity(body RID.Body2D, axis_velocity Vector2.XY)

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.

func BodySetCollisionLayer

func BodySetCollisionLayer(body RID.Body2D, layer int)

Sets the physics layer or layers the body belongs to, via a bitmask.

func BodySetCollisionMask

func BodySetCollisionMask(body RID.Body2D, mask int)

Sets the physics layer or layers the body can collide with, via a bitmask.

func BodySetCollisionPriority

func BodySetCollisionPriority(body RID.Body2D, priority Float.X)

Sets the body's collision priority. This is used in the depenetration phase of BodyTestMotion. The higher the priority is, the lower the penetration into the body will be.

func BodySetConstantForce

func BodySetConstantForce(body RID.Body2D, force Vector2.XY)

Sets the body's total constant positional force applied during each physics update.

See BodyAddConstantForce and BodyAddConstantCentralForce.

func BodySetConstantTorque

func BodySetConstantTorque(body RID.Body2D, torque Float.X)

Sets the body's total constant rotational force applied during each physics update.

See BodyAddConstantTorque.

func BodySetContinuousCollisionDetectionMode

func BodySetContinuousCollisionDetectionMode(body RID.Body2D, mode CCDMode)

Sets the continuous collision detection mode.

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.

func BodySetForceIntegrationCallback

func BodySetForceIntegrationCallback(body RID.Body2D, callable func(state PhysicsDirectBodyState2D.Instance, userdata any), userdata any)

Sets the body's custom force integration callback function to 'callable'. Use an empty func (Callable()) to clear the custom callback.

The function 'callable' will be called every physics tick, before the standard force integration (see BodySetOmitForceIntegration). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.

If 'userdata' is not null, the function 'callable' must take the following two parameters:

1. state: a graphics.gd/classdb/PhysicsDirectBodyState2D used to retrieve and modify the body's state,

2. userdata: a any; its value will be the 'userdata' passed into this method.

If 'userdata' is null, then 'callable' must take only the state parameter.

func BodySetForceIntegrationCallbackOptions

func BodySetForceIntegrationCallbackOptions(body RID.Body2D, callable func(state PhysicsDirectBodyState2D.Instance, userdata any), userdata any)

Sets the body's custom force integration callback function to 'callable'. Use an empty func (Callable()) to clear the custom callback.

The function 'callable' will be called every physics tick, before the standard force integration (see BodySetOmitForceIntegration). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.

If 'userdata' is not null, the function 'callable' must take the following two parameters:

1. state: a graphics.gd/classdb/PhysicsDirectBodyState2D used to retrieve and modify the body's state,

2. userdata: a any; its value will be the 'userdata' passed into this method.

If 'userdata' is null, then 'callable' must take only the state parameter.

func BodySetMaxContactsReported

func BodySetMaxContactsReported(body RID.Body2D, amount int)

Sets the maximum number of contacts that the body can report. If 'amount' is greater than zero, then the body will keep track of at most this many contacts with other bodies.

func BodySetMode

func BodySetMode(body RID.Body2D, mode BodyMode)

Sets the body's mode.

func BodySetOmitForceIntegration

func BodySetOmitForceIntegration(body RID.Body2D, enable bool)

Sets whether the body omits the standard force integration. If '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, BodySetForceIntegrationCallback can be used to manually update the linear and angular velocity instead.

This method is called when the property graphics.gd/classdb/RigidBody2D.Instance.CustomIntegrator is set.

func BodySetParam

func BodySetParam(body RID.Body2D, param BodyParameter, value any)

Sets the value of the given body parameter.

func BodySetShape

func BodySetShape(body RID.Body2D, shape_idx int, shape RID.Shape2D)

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.

func BodySetShapeAsOneWayCollision

func BodySetShapeAsOneWayCollision(body RID.Body2D, shape_idx int, enable bool, margin Float.X)

Sets the one-way collision properties of the body's shape with the given index. If '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.

func BodySetShapeDisabled

func BodySetShapeDisabled(body RID.Body2D, shape_idx int, disabled bool)

Sets the disabled property of the body's shape with the given index. If 'disabled' is true, then the shape will be ignored in all collision detection.

func BodySetShapeTransform

func BodySetShapeTransform(body RID.Body2D, shape_idx int, transform Transform2D.OriginXY)

Sets the local transform matrix of the body's shape with the given index.

func BodySetSpace

func BodySetSpace(body RID.Body2D, space RID.Space2D)

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 BodyModeRigid, then adding the body to a space will have the following additional effects:

- If the parameter BodyParamCenterOfMass has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.

- If the parameter BodyParamInertia 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()).

func BodySetState

func BodySetState(body RID.Body2D, state BodyState, value any)

Sets the value of a body's state.

Note: The state change doesn't take effect immediately. The state will change on the next physics frame.

func BodySetStateSyncCallback

func BodySetStateSyncCallback(body RID.Body2D, callable func(state PhysicsDirectBodyState2D.Instance))

Sets the body's state synchronization callback function to 'callable'. Use an empty func (Callable()) to clear the callback.

The function '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 'callable' must take the following parameters:

1. state: a graphics.gd/classdb/PhysicsDirectBodyState2D, used to retrieve the body's state.

func BodyTestMotion

Returns true if a collision would result from moving the body along a motion vector from a given point in space. See graphics.gd/classdb/PhysicsTestMotionParameters2D for the available motion parameters. Optionally a graphics.gd/classdb/PhysicsTestMotionResult2D object can be passed, which will be used to store the information about the resulting collision.

func BodyTestMotionOptions

func BodyTestMotionOptions(body RID.Body2D, parameters PhysicsTestMotionParameters2D.Instance, result PhysicsTestMotionResult2D.Instance) bool

Returns true if a collision would result from moving the body along a motion vector from a given point in space. See graphics.gd/classdb/PhysicsTestMotionParameters2D for the available motion parameters. Optionally a graphics.gd/classdb/PhysicsTestMotionResult2D object can be passed, which will be used to store the information about the resulting collision.

func CapsuleShapeCreate

func CapsuleShapeCreate() RID.Shape2D

Creates a 2D capsule shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the capsule's height and radius.

func CircleShapeCreate

func CircleShapeCreate() RID.Shape2D

Creates a 2D circle shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the circle's radius.

func ConcavePolygonShapeCreate

func ConcavePolygonShapeCreate() RID.Shape2D

Creates a 2D concave polygon shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the concave polygon's segments.

func ConvexPolygonShapeCreate

func ConvexPolygonShapeCreate() RID.Shape2D

Creates a 2D convex polygon shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the convex polygon's points.

func DampedSpringJointGetParam

func DampedSpringJointGetParam(joint RID.Joint2D, param DampedSpringParam) Float.X

Returns the value of the given damped spring joint parameter.

func DampedSpringJointSetParam

func DampedSpringJointSetParam(joint RID.Joint2D, param DampedSpringParam, value Float.X)

Sets the value of the given damped spring joint parameter.

func FreeRid

func FreeRid(rid RID.Any)

Destroys any of the objects created by PhysicsServer2D. If the [Resource.ID] passed is not one of the objects that can be created by PhysicsServer2D, an error will be printed to the console.

func GetProcessInfo

func GetProcessInfo(process_info ProcessInfo) int

Returns the value of a physics engine state specified by 'process_info'.

func JointClear

func JointClear(joint RID.Joint2D)

Destroys the joint with the given [Resource.ID], creates a new uninitialized joint, and makes the [Resource.ID] refer to this new joint.

func JointCreate

func JointCreate() RID.Joint2D

Creates a 2D joint in the physics server, and returns the [Resource.ID] that identifies it. To set the joint type, use JointMakeDampedSpring, JointMakeGroove or JointMakePin. Use JointSetParam to set generic joint parameters.

func JointDisableCollisionsBetweenBodies

func JointDisableCollisionsBetweenBodies(joint RID.Joint2D, disable bool)

Sets whether the bodies attached to the graphics.gd/classdb/Joint2D will collide with each other.

func JointGetParam

func JointGetParam(joint RID.Joint2D, param JointParam) Float.X

Returns the value of the given joint parameter.

func JointIsDisabledCollisionsBetweenBodies

func JointIsDisabledCollisionsBetweenBodies(joint RID.Joint2D) bool

Returns whether the bodies attached to the graphics.gd/classdb/Joint2D will collide with each other.

func JointMakeDampedSpring

func JointMakeDampedSpring(joint RID.Joint2D, anchor_a Vector2.XY, anchor_b Vector2.XY, body_a RID.Body2D, body_b RID.Body2D)

Makes the joint a damped spring joint, attached at the point 'anchor_a' (given in global coordinates) on the body 'body_a' and at the point 'anchor_b' (given in global coordinates) on the body 'body_b'. To set the parameters which are specific to the damped spring, see DampedSpringJointSetParam.

func JointMakeDampedSpringOptions

func JointMakeDampedSpringOptions(joint RID.Joint2D, anchor_a Vector2.XY, anchor_b Vector2.XY, body_a RID.Body2D, body_b RID.Body2D)

Makes the joint a damped spring joint, attached at the point 'anchor_a' (given in global coordinates) on the body 'body_a' and at the point 'anchor_b' (given in global coordinates) on the body 'body_b'. To set the parameters which are specific to the damped spring, see DampedSpringJointSetParam.

func JointMakeGroove

func JointMakeGroove(joint RID.Joint2D, groove1_a Vector2.XY, groove2_a Vector2.XY, anchor_b Vector2.XY, body_a RID.Body2D, body_b RID.Body2D)

Makes the joint a groove joint.

func JointMakeGrooveOptions

func JointMakeGrooveOptions(joint RID.Joint2D, groove1_a Vector2.XY, groove2_a Vector2.XY, anchor_b Vector2.XY, body_a RID.Body2D, body_b RID.Body2D)

Makes the joint a groove joint.

func JointMakePin

func JointMakePin(joint RID.Joint2D, anchor Vector2.XY, body_a RID.Body2D, body_b RID.Body2D)

Makes the joint a pin joint. If 'body_b' is an empty [Resource.ID], then 'body_a' is pinned to the point 'anchor' (given in global coordinates); otherwise, 'body_a' is pinned to 'body_b' at the point 'anchor' (given in global coordinates). To set the parameters which are specific to the pin joint, see PinJointSetParam.

func JointMakePinOptions

func JointMakePinOptions(joint RID.Joint2D, anchor Vector2.XY, body_a RID.Body2D, body_b RID.Body2D)

Makes the joint a pin joint. If 'body_b' is an empty [Resource.ID], then 'body_a' is pinned to the point 'anchor' (given in global coordinates); otherwise, 'body_a' is pinned to 'body_b' at the point 'anchor' (given in global coordinates). To set the parameters which are specific to the pin joint, see PinJointSetParam.

func JointSetParam

func JointSetParam(joint RID.Joint2D, param JointParam, value Float.X)

Sets the value of the given joint parameter.

func PinJointGetFlag

func PinJointGetFlag(joint RID.Joint2D, flag PinJointFlag) bool

Gets a pin joint flag.

func PinJointGetParam

func PinJointGetParam(joint RID.Joint2D, param PinJointParam) Float.X

Returns the value of a pin joint parameter.

func PinJointSetFlag

func PinJointSetFlag(joint RID.Joint2D, flag PinJointFlag, enabled bool)

Sets a pin joint flag.

func PinJointSetParam

func PinJointSetParam(joint RID.Joint2D, param PinJointParam, value Float.X)

Sets a pin joint parameter.

func RectangleShapeCreate

func RectangleShapeCreate() RID.Shape2D

Creates a 2D rectangle shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the rectangle's half-extents.

func SegmentShapeCreate

func SegmentShapeCreate() RID.Shape2D

Creates a 2D segment shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the segment's start and end points.

func SeparationRayShapeCreate

func SeparationRayShapeCreate() RID.Shape2D

Creates a 2D separation ray shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the shape's length and slide_on_slope properties.

func SetActive

func SetActive(active bool)

Activates or deactivates the 2D physics server. If 'active' is false, then the physics server will not do anything in its physics step.

func ShapeGetData

func ShapeGetData(shape RID.Shape2D) any

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 ShapeSetData for the precise format of this data in each case.

func ShapeSetData

func ShapeSetData(shape RID.Shape2D, data any)

Sets the shape data that defines the configuration of the shape. The 'data' to be passed depends on the shape's type (see ShapeGetType):

- ShapeWorldBoundary: an array of length two containing a [Vector2.XY] normal direction and a [Float.X] distance d,

- ShapeSeparationRay: a dictionary containing the key length with a [Float.X] value and the key slide_on_slope with a bool value,

- ShapeSegment: a [Rect2.PositionSize] rect containing the first point of the segment in rect.position and the second point of the segment in rect.size,

- ShapeCircle: a [Float.X] radius,

- ShapeRectangle: a [Vector2.XY] half_extents,

- ShapeCapsule: an array of length two (or a [Vector2.XY]) containing a [Float.X] height and a [Float.X] radius,

- ShapeConvexPolygon: either a [][Vector2.XY] 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 []float32 of length divisible by four so that every 4-tuple of [Float.X]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,

- ShapeConcavePolygon: a [][Vector2.XY] of length divisible by two (each pair of points forms one segment).

Warning: In the case of ShapeConvexPolygon, this method does not check if the points supplied actually form a convex polygon (unlike the graphics.gd/classdb/CollisionPolygon2D.Instance.Polygon property).

func SpaceCreate

func SpaceCreate() RID.Space2D

Creates a 2D space in the physics server, and returns the [Resource.ID] that identifies it. A space contains bodies and areas, and controls the stepping of the physics simulation of the objects in it.

func SpaceGetDirectState

func SpaceGetDirectState(space RID.Space2D) PhysicsDirectSpaceState2D.Instance

Returns the state of a space, a graphics.gd/classdb/PhysicsDirectSpaceState2D. This object can be used for collision/intersection queries.

func SpaceGetParam

func SpaceGetParam(space RID.Space2D, param SpaceParameter) Float.X

Returns the value of the given space parameter.

func SpaceIsActive

func SpaceIsActive(space RID.Space2D) bool

Returns true if the space is active.

func SpaceSetActive

func SpaceSetActive(space RID.Space2D, active bool)

Activates or deactivates the space. If 'active' is false, then the physics server will not do anything with this space in its physics step.

func SpaceSetParam

func SpaceSetParam(space RID.Space2D, param SpaceParameter, value Float.X)

Sets the value of the given space parameter.

func WorldBoundaryShapeCreate

func WorldBoundaryShapeCreate() RID.Shape2D

Creates a 2D world boundary shape in the physics server, and returns the [Resource.ID] that identifies it. Use ShapeSetData to set the shape's normal direction and distance properties.

Types

type AreaBodyStatus

type AreaBodyStatus int //gd:PhysicsServer2D.AreaBodyStatus
const (
	// The value of the first parameter and area callback function receives, when an object enters one of its shapes.
	AreaBodyAdded AreaBodyStatus = 0
	// The value of the first parameter and area callback function receives, when an object exits one of its shapes.
	AreaBodyRemoved AreaBodyStatus = 1
)

type AreaParameter

type AreaParameter int //gd:PhysicsServer2D.AreaParameter
const (
	// Constant to set/get gravity override mode in an area. See [AreaSpaceOverrideMode] for possible values. The default value of this parameter is [AreaSpaceOverrideDisabled].
	AreaParamGravityOverrideMode AreaParameter = 0
	// Constant to set/get gravity strength in an area. The default value of this parameter is 9.80665.
	AreaParamGravity AreaParameter = 1
	// Constant to set/get gravity vector/center in an area. The default value of this parameter is Vector2(0, -1).
	AreaParamGravityVector AreaParameter = 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.
	AreaParamGravityIsPoint AreaParameter = 3
	// Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by [AreaParamGravity]. 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.
	AreaParamGravityPointUnitDistance AreaParameter = 4
	// Constant to set/get linear damping override mode in an area. See [AreaSpaceOverrideMode] for possible values. The default value of this parameter is [AreaSpaceOverrideDisabled].
	AreaParamLinearDampOverrideMode AreaParameter = 5
	// Constant to set/get the linear damping factor of an area. The default value of this parameter is 0.1.
	AreaParamLinearDamp AreaParameter = 6
	// Constant to set/get angular damping override mode in an area. See [AreaSpaceOverrideMode] for possible values. The default value of this parameter is [AreaSpaceOverrideDisabled].
	AreaParamAngularDampOverrideMode AreaParameter = 7
	// Constant to set/get the angular damping factor of an area. The default value of this parameter is 1.0.
	AreaParamAngularDamp AreaParameter = 8
	// Constant to set/get the priority (order of processing) of an area. The default value of this parameter is 0.
	AreaParamPriority AreaParameter = 9
)

type AreaSpaceOverrideMode

type AreaSpaceOverrideMode int //gd:PhysicsServer2D.AreaSpaceOverrideMode
const (
	// This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
	AreaSpaceOverrideDisabled AreaSpaceOverrideMode = 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.
	AreaSpaceOverrideCombine AreaSpaceOverrideMode = 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.
	AreaSpaceOverrideCombineReplace AreaSpaceOverrideMode = 2
	// This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
	AreaSpaceOverrideReplace AreaSpaceOverrideMode = 3
	// This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
	AreaSpaceOverrideReplaceCombine AreaSpaceOverrideMode = 4
)

type BodyDampMode

type BodyDampMode int //gd:PhysicsServer2D.BodyDampMode
const (
	// The body's damping value is added to any value set in areas or the default value.
	BodyDampModeCombine BodyDampMode = 0
	// The body's damping value replaces any value set in areas or the default value.
	BodyDampModeReplace BodyDampMode = 1
)

type BodyMode

type BodyMode int //gd:PhysicsServer2D.BodyMode
const (
	// 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.
	BodyModeStatic BodyMode = 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.
	BodyModeKinematic BodyMode = 1
	// Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied.
	BodyModeRigid BodyMode = 2
	// Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces.
	BodyModeRigidLinear BodyMode = 3
)

func BodyGetMode

func BodyGetMode(body RID.Body2D) BodyMode

Returns the body's mode.

type BodyParameter

type BodyParameter int //gd:PhysicsServer2D.BodyParameter
const (
	// Constant to set/get a body's bounce factor. The default value of this parameter is 0.0.
	BodyParamBounce BodyParameter = 0
	// Constant to set/get a body's friction. The default value of this parameter is 1.0.
	BodyParamFriction BodyParameter = 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 [BodyModeRigid], then setting this parameter will have the following additional effects:
	//
	// - If the parameter [BodyParamCenterOfMass] has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.
	//
	// - If the parameter [BodyParamInertia] 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.
	BodyParamMass BodyParameter = 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.
	BodyParamInertia BodyParameter = 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 [BodyParamMass] or when calling [Instance.BodySetSpace].
	BodyParamCenterOfMass BodyParameter = 4
	// Constant to set/get a body's gravity multiplier. The default value of this parameter is 1.0.
	BodyParamGravityScale BodyParameter = 5
	// Constant to set/get a body's linear damping mode. See [BodyDampMode] for possible values. The default value of this parameter is [BodyDampModeCombine].
	BodyParamLinearDampMode BodyParameter = 6
	// Constant to set/get a body's angular damping mode. See [BodyDampMode] for possible values. The default value of this parameter is [BodyDampModeCombine].
	BodyParamAngularDampMode BodyParameter = 7
	// Constant to set/get a body's linear damping factor. The default value of this parameter is 0.0.
	BodyParamLinearDamp BodyParameter = 8
	// Constant to set/get a body's angular damping factor. The default value of this parameter is 0.0.
	BodyParamAngularDamp BodyParameter = 9
	// Represents the size of the [BodyParameter] enum.
	BodyParamMax BodyParameter = 10
)

type BodyState

type BodyState int //gd:PhysicsServer2D.BodyState
const (
	// Constant to set/get the current transform matrix of the body.
	BodyStateTransform BodyState = 0
	// Constant to set/get the current linear velocity of the body.
	BodyStateLinearVelocity BodyState = 1
	// Constant to set/get the current angular velocity of the body.
	BodyStateAngularVelocity BodyState = 2
	// Constant to sleep/wake up a body, or to get whether it is sleeping.
	BodyStateSleeping BodyState = 3
	// Constant to set/get whether the body can sleep.
	BodyStateCanSleep BodyState = 4
)

type CCDMode

type CCDMode int //gd:PhysicsServer2D.CCDMode
const (
	// Disables continuous collision detection. This is the fastest way to detect body collisions, but it can miss small and/or fast-moving objects.
	CcdModeDisabled CCDMode = 0
	// Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
	CcdModeCastRay CCDMode = 1
	// Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
	CcdModeCastShape CCDMode = 2
)

func BodyGetContinuousCollisionDetectionMode

func BodyGetContinuousCollisionDetectionMode(body RID.Body2D) CCDMode

Returns the body's continuous collision detection mode.

type DampedSpringParam

type DampedSpringParam int //gd:PhysicsServer2D.DampedSpringParam
const (
	// 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.
	DampedSpringRestLength DampedSpringParam = 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.
	DampedSpringStiffness DampedSpringParam = 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.
	DampedSpringDamping DampedSpringParam = 2
)

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.PhysicsServer2D

Instance of the class with convieniently typed arguments and results.

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type JointParam

type JointParam int //gd:PhysicsServer2D.JointParam
const (
	// 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.
	JointParamBias JointParam = 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.
	JointParamMaxBias JointParam = 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.
	JointParamMaxForce JointParam = 2
)

type JointType

type JointType int //gd:PhysicsServer2D.JointType
const (
	// Constant to create pin joints.
	JointTypePin JointType = 0
	// Constant to create groove joints.
	JointTypeGroove JointType = 1
	// Constant to create damped spring joints.
	JointTypeDampedSpring JointType = 2
	// Represents the size of the [JointType] enum.
	JointTypeMax JointType = 3
)

func JointGetType

func JointGetType(joint RID.Joint2D) JointType

Returns the joint's type.

type PinJointFlag

type PinJointFlag int //gd:PhysicsServer2D.PinJointFlag
const (
	// If true, the pin has a maximum and a minimum rotation.
	PinJointFlagAngularLimitEnabled PinJointFlag = 0
	// If true, a motor turns the pin.
	PinJointFlagMotorEnabled PinJointFlag = 1
)

type PinJointParam

type PinJointParam int //gd:PhysicsServer2D.PinJointParam
const (
	// Constant to set/get a how much the bond of the pin joint can flex. The default value of this parameter is 0.0.
	PinJointSoftness PinJointParam = 0
	// The maximum rotation around the pin.
	PinJointLimitUpper PinJointParam = 1
	// The minimum rotation around the pin.
	PinJointLimitLower PinJointParam = 2
	// Target speed for the motor. In radians per second.
	PinJointMotorTargetVelocity PinJointParam = 3
)

type ProcessInfo

type ProcessInfo int //gd:PhysicsServer2D.ProcessInfo
const (
	// Constant to get the number of objects that are not sleeping.
	InfoActiveObjects ProcessInfo = 0
	// Constant to get the number of possible collisions.
	InfoCollisionPairs ProcessInfo = 1
	// Constant to get the number of space regions where a collision could occur.
	InfoIslandCount ProcessInfo = 2
)

type ShapeType

type ShapeType int //gd:PhysicsServer2D.ShapeType
const (
	// 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.
	ShapeWorldBoundary ShapeType = 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.
	ShapeSeparationRay ShapeType = 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.
	ShapeSegment ShapeType = 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.
	ShapeCircle ShapeType = 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.
	ShapeRectangle ShapeType = 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.
	ShapeCapsule ShapeType = 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.
	ShapeConvexPolygon ShapeType = 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.
	ShapeConcavePolygon ShapeType = 7
	// This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
	ShapeCustom ShapeType = 8
)

func ShapeGetType

func ShapeGetType(shape RID.Shape2D) ShapeType

Returns the shape's type.

type SpaceParameter

type SpaceParameter int //gd:PhysicsServer2D.SpaceParameter
const (
	// 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/solver/contact_recycle_radius".
	SpaceParamContactRecycleRadius SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/solver/contact_max_separation".
	SpaceParamContactMaxSeparation SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/solver/contact_max_allowed_penetration".
	SpaceParamContactMaxAllowedPenetration SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/solver/default_contact_bias".
	SpaceParamContactDefaultBias SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/sleep_threshold_linear".
	SpaceParamBodyLinearVelocitySleepThreshold SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/sleep_threshold_angular".
	SpaceParamBodyAngularVelocitySleepThreshold SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/time_before_sleep".
	SpaceParamBodyTimeToSleep SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/solver/default_constraint_bias".
	SpaceParamConstraintDefaultBias SpaceParameter = 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 [graphics.gd/classdb/ProjectSettings] "physics/2d/solver/solver_iterations".
	SpaceParamSolverIterations SpaceParameter = 8
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL