Table of Contents

Class PhysicsServer3DInstance

Namespace
Godot
Assembly
GodotSharp.dll

PhysicsServer3D is the server responsible for all 3D 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 sphere, a box, a cylinder, 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 PhysicsServer3D may be created and manipulated independently; they do not have to be tied to nodes in the scene tree.

Note: All the 3D 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.

[GodotClassName("PhysicsServer3D")]
public class PhysicsServer3DInstance : GodotObject, IDisposable
Inheritance
PhysicsServer3DInstance
Implements
Derived
Inherited Members

Methods

AreaAddShape(Rid, Rid, Transform3D?, bool)

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.

public void AreaAddShape(Rid area, Rid shape, Transform3D? transform = null, bool disabled = false)

Parameters

area Rid
shape Rid
transform Transform3D?

If the parameter is null, then the default value is Transform3D.Identity.

disabled bool

AreaAttachObjectInstanceId(Rid, ulong)

Assigns the area to a descendant of GodotObject, so it can exist in the node tree.

public void AreaAttachObjectInstanceId(Rid area, ulong id)

Parameters

area Rid
id ulong

AreaClearShapes(Rid)

Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.

public void AreaClearShapes(Rid area)

Parameters

area Rid

AreaCreate()

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 AreaAddShape(Rid, Rid, Transform3D?, bool) to add shapes to it, use AreaSetTransform(Rid, Transform3D) to set its transform, and use AreaSetSpace(Rid, Rid) to add the area to a space. If you want the area to be detectable use AreaSetMonitorable(Rid, bool).

public Rid AreaCreate()

Returns

Rid

AreaGetCollisionLayer(Rid)

Returns the physics layer or layers an area belongs to.

public uint AreaGetCollisionLayer(Rid area)

Parameters

area Rid

Returns

uint

AreaGetCollisionMask(Rid)

Returns the physics layer or layers an area can contact with.

public uint AreaGetCollisionMask(Rid area)

Parameters

area Rid

Returns

uint

AreaGetObjectInstanceId(Rid)

Gets the instance ID of the object the area is assigned to.

public ulong AreaGetObjectInstanceId(Rid area)

Parameters

area Rid

Returns

ulong

AreaGetParam(Rid, AreaParameter)

Returns an area parameter value. A list of available parameters is on the PhysicsServer3D.AreaParameter constants.

public Variant AreaGetParam(Rid area, PhysicsServer3D.AreaParameter param)

Parameters

area Rid
param PhysicsServer3D.AreaParameter

Returns

Variant

AreaGetShape(Rid, int)

Returns the Rid of the nth shape of an area.

public Rid AreaGetShape(Rid area, int shapeIdx)

Parameters

area Rid
shapeIdx int

Returns

Rid

AreaGetShapeCount(Rid)

Returns the number of shapes assigned to an area.

public int AreaGetShapeCount(Rid area)

Parameters

area Rid

Returns

int

AreaGetShapeTransform(Rid, int)

Returns the transform matrix of a shape within an area.

public Transform3D AreaGetShapeTransform(Rid area, int shapeIdx)

Parameters

area Rid
shapeIdx int

Returns

Transform3D

AreaGetSpace(Rid)

Returns the space assigned to the area.

public Rid AreaGetSpace(Rid area)

Parameters

area Rid

Returns

Rid

AreaGetTransform(Rid)

Returns the transform matrix for an area.

public Transform3D AreaGetTransform(Rid area)

Parameters

area Rid

Returns

Transform3D

AreaRemoveShape(Rid, int)

Removes a shape from an area. It does not delete the shape, so it can be reassigned later.

public void AreaRemoveShape(Rid area, int shapeIdx)

Parameters

area Rid
shapeIdx int

AreaSetAreaMonitorCallback(Rid, Callable)

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

2. an Ridarea_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.

public void AreaSetAreaMonitorCallback(Rid area, Callable callback)

Parameters

area Rid
callback Callable

AreaSetCollisionLayer(Rid, uint)

Assigns the area to one or many physics layers.

public void AreaSetCollisionLayer(Rid area, uint layer)

Parameters

area Rid
layer uint

AreaSetCollisionMask(Rid, uint)

Sets which physics layers the area will monitor.

public void AreaSetCollisionMask(Rid area, uint mask)

Parameters

area Rid
mask uint

AreaSetMonitorCallback(Rid, Callable)

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

2. an Ridbody_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.

public void AreaSetMonitorCallback(Rid area, Callable callback)

Parameters

area Rid
callback Callable

AreaSetMonitorable(Rid, bool)

public void AreaSetMonitorable(Rid area, bool monitorable)

Parameters

area Rid
monitorable bool

AreaSetParam(Rid, AreaParameter, Variant)

Sets the value for an area parameter. A list of available parameters is on the PhysicsServer3D.AreaParameter constants.

public void AreaSetParam(Rid area, PhysicsServer3D.AreaParameter param, Variant value)

Parameters

area Rid
param PhysicsServer3D.AreaParameter
value Variant

AreaSetRayPickable(Rid, bool)

Sets object pickable with rays.

public void AreaSetRayPickable(Rid area, bool enable)

Parameters

area Rid
enable bool

AreaSetShape(Rid, int, Rid)

Substitutes a given area shape by another. The old shape is selected by its index, the new one by its Rid.

public void AreaSetShape(Rid area, int shapeIdx, Rid shape)

Parameters

area Rid
shapeIdx int
shape Rid

AreaSetShapeDisabled(Rid, int, bool)

public void AreaSetShapeDisabled(Rid area, int shapeIdx, bool disabled)

Parameters

area Rid
shapeIdx int
disabled bool

AreaSetShapeTransform(Rid, int, Transform3D)

Sets the transform matrix for an area shape.

public void AreaSetShapeTransform(Rid area, int shapeIdx, Transform3D transform)

Parameters

area Rid
shapeIdx int
transform Transform3D

AreaSetSpace(Rid, Rid)

Assigns a space to the area.

public void AreaSetSpace(Rid area, Rid space)

Parameters

area Rid
space Rid

AreaSetTransform(Rid, Transform3D)

Sets the transform matrix for an area.

public void AreaSetTransform(Rid area, Transform3D transform)

Parameters

area Rid
transform Transform3D

BodyAddCollisionException(Rid, Rid)

Adds a body to the list of bodies exempt from collisions.

public void BodyAddCollisionException(Rid body, Rid exceptedBody)

Parameters

body Rid
exceptedBody Rid

BodyAddConstantCentralForce(Rid, Vector3)

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 BodyAddConstantForce(Rid, Vector3, Vector3?) at the body's center of mass.

public void BodyAddConstantCentralForce(Rid body, Vector3 force)

Parameters

body Rid
force Vector3

BodyAddConstantForce(Rid, Vector3, Vector3?)

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

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

public void BodyAddConstantForce(Rid body, Vector3 force, Vector3? position = null)

Parameters

body Rid
force Vector3
position Vector3?

If the parameter is null, then the default value is new Vector3(0, 0, 0).

BodyAddConstantTorque(Rid, Vector3)

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

public void BodyAddConstantTorque(Rid body, Vector3 torque)

Parameters

body Rid
torque Vector3

BodyAddShape(Rid, Rid, Transform3D?, bool)

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.

public void BodyAddShape(Rid body, Rid shape, Transform3D? transform = null, bool disabled = false)

Parameters

body Rid
shape Rid
transform Transform3D?

If the parameter is null, then the default value is Transform3D.Identity.

disabled bool

BodyApplyCentralForce(Rid, Vector3)

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 BodyApplyForce(Rid, Vector3, Vector3?) at the body's center of mass.

public void BodyApplyCentralForce(Rid body, Vector3 force)

Parameters

body Rid
force Vector3

BodyApplyCentralImpulse(Rid, Vector3)

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 BodyApplyImpulse(Rid, Vector3, Vector3?) at the body's center of mass.

public void BodyApplyCentralImpulse(Rid body, Vector3 impulse)

Parameters

body Rid
impulse Vector3

BodyApplyForce(Rid, Vector3, Vector3?)

Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.

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

public void BodyApplyForce(Rid body, Vector3 force, Vector3? position = null)

Parameters

body Rid
force Vector3
position Vector3?

If the parameter is null, then the default value is new Vector3(0, 0, 0).

BodyApplyImpulse(Rid, Vector3, Vector3?)

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

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

public void BodyApplyImpulse(Rid body, Vector3 impulse, Vector3? position = null)

Parameters

body Rid
impulse Vector3
position Vector3?

If the parameter is null, then the default value is new Vector3(0, 0, 0).

BodyApplyTorque(Rid, Vector3)

Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.

public void BodyApplyTorque(Rid body, Vector3 torque)

Parameters

body Rid
torque Vector3

BodyApplyTorqueImpulse(Rid, Vector3)

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

public void BodyApplyTorqueImpulse(Rid body, Vector3 impulse)

Parameters

body Rid
impulse Vector3

BodyAttachObjectInstanceId(Rid, ulong)

Assigns the area to a descendant of GodotObject, so it can exist in the node tree.

public void BodyAttachObjectInstanceId(Rid body, ulong id)

Parameters

body Rid
id ulong

BodyClearShapes(Rid)

Removes all shapes from a body.

public void BodyClearShapes(Rid body)

Parameters

body Rid

BodyCreate()

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

Use BodyAddShape(Rid, Rid, Transform3D?, bool) to add shapes to it, use BodySetState(Rid, BodyState, Variant) to set its transform, and use BodySetSpace(Rid, Rid) to add the body to a space.

public Rid BodyCreate()

Returns

Rid

BodyGetCollisionLayer(Rid)

Returns the physics layer or layers a body belongs to.

public uint BodyGetCollisionLayer(Rid body)

Parameters

body Rid

Returns

uint

BodyGetCollisionMask(Rid)

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

public uint BodyGetCollisionMask(Rid body)

Parameters

body Rid

Returns

uint

BodyGetCollisionPriority(Rid)

Returns the body's collision priority.

public float BodyGetCollisionPriority(Rid body)

Parameters

body Rid

Returns

float

BodyGetConstantForce(Rid)

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

See BodyAddConstantForce(Rid, Vector3, Vector3?) and BodyAddConstantCentralForce(Rid, Vector3).

public Vector3 BodyGetConstantForce(Rid body)

Parameters

body Rid

Returns

Vector3

BodyGetConstantTorque(Rid)

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

See BodyAddConstantTorque(Rid, Vector3).

public Vector3 BodyGetConstantTorque(Rid body)

Parameters

body Rid

Returns

Vector3

BodyGetDirectState(Rid)

Returns the PhysicsDirectBodyState3D of the body. Returns null if the body is destroyed or removed from the physics space.

public PhysicsDirectBodyState3D BodyGetDirectState(Rid body)

Parameters

body Rid

Returns

PhysicsDirectBodyState3D

BodyGetMaxContactsReported(Rid)

Returns the maximum contacts that can be reported. See BodySetMaxContactsReported(Rid, int).

public int BodyGetMaxContactsReported(Rid body)

Parameters

body Rid

Returns

int

BodyGetMode(Rid)

Returns the body mode.

public PhysicsServer3D.BodyMode BodyGetMode(Rid body)

Parameters

body Rid

Returns

PhysicsServer3D.BodyMode

BodyGetObjectInstanceId(Rid)

Gets the instance ID of the object the area is assigned to.

public ulong BodyGetObjectInstanceId(Rid body)

Parameters

body Rid

Returns

ulong

BodyGetParam(Rid, BodyParameter)

Returns the value of a body parameter. A list of available parameters is on the PhysicsServer3D.BodyParameter constants.

public Variant BodyGetParam(Rid body, PhysicsServer3D.BodyParameter param)

Parameters

body Rid
param PhysicsServer3D.BodyParameter

Returns

Variant

BodyGetShape(Rid, int)

Returns the Rid of the nth shape of a body.

public Rid BodyGetShape(Rid body, int shapeIdx)

Parameters

body Rid
shapeIdx int

Returns

Rid

BodyGetShapeCount(Rid)

Returns the number of shapes assigned to a body.

public int BodyGetShapeCount(Rid body)

Parameters

body Rid

Returns

int

BodyGetShapeTransform(Rid, int)

Returns the transform matrix of a body shape.

public Transform3D BodyGetShapeTransform(Rid body, int shapeIdx)

Parameters

body Rid
shapeIdx int

Returns

Transform3D

BodyGetSpace(Rid)

Returns the Rid of the space assigned to a body.

public Rid BodyGetSpace(Rid body)

Parameters

body Rid

Returns

Rid

BodyGetState(Rid, BodyState)

Returns a body state.

public Variant BodyGetState(Rid body, PhysicsServer3D.BodyState state)

Parameters

body Rid
state PhysicsServer3D.BodyState

Returns

Variant

BodyIsAxisLocked(Rid, BodyAxis)

public bool BodyIsAxisLocked(Rid body, PhysicsServer3D.BodyAxis axis)

Parameters

body Rid
axis PhysicsServer3D.BodyAxis

Returns

bool

BodyIsContinuousCollisionDetectionEnabled(Rid)

If true, the continuous collision detection mode is enabled.

public bool BodyIsContinuousCollisionDetectionEnabled(Rid body)

Parameters

body Rid

Returns

bool

BodyIsOmittingForceIntegration(Rid)

Returns true if the body is omitting the standard force integration. See BodySetOmitForceIntegration(Rid, bool).

public bool BodyIsOmittingForceIntegration(Rid body)

Parameters

body Rid

Returns

bool

BodyRemoveCollisionException(Rid, Rid)

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.

public void BodyRemoveCollisionException(Rid body, Rid exceptedBody)

Parameters

body Rid
exceptedBody Rid

BodyRemoveShape(Rid, int)

Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.

public void BodyRemoveShape(Rid body, int shapeIdx)

Parameters

body Rid
shapeIdx int

BodyResetMassProperties(Rid)

Restores the default inertia and center of mass based on shapes to cancel any custom values previously set using BodySetParam(Rid, BodyParameter, Variant).

public void BodyResetMassProperties(Rid body)

Parameters

body Rid

BodySetAxisLock(Rid, BodyAxis, bool)

public void BodySetAxisLock(Rid body, PhysicsServer3D.BodyAxis axis, bool @lock)

Parameters

body Rid
axis PhysicsServer3D.BodyAxis
lock bool

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

public void BodySetAxisVelocity(Rid body, Vector3 axisVelocity)

Parameters

body Rid
axisVelocity Vector3

BodySetCollisionLayer(Rid, uint)

Sets the physics layer or layers a body belongs to.

public void BodySetCollisionLayer(Rid body, uint layer)

Parameters

body Rid
layer uint

BodySetCollisionMask(Rid, uint)

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

public void BodySetCollisionMask(Rid body, uint mask)

Parameters

body Rid
mask uint

BodySetCollisionPriority(Rid, float)

Sets the body's collision priority.

public void BodySetCollisionPriority(Rid body, float priority)

Parameters

body Rid
priority float

BodySetConstantForce(Rid, Vector3)

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

See BodyAddConstantForce(Rid, Vector3, Vector3?) and BodyAddConstantCentralForce(Rid, Vector3).

public void BodySetConstantForce(Rid body, Vector3 force)

Parameters

body Rid
force Vector3

BodySetConstantTorque(Rid, Vector3)

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

See BodyAddConstantTorque(Rid, Vector3).

public void BodySetConstantTorque(Rid body, Vector3 torque)

Parameters

body Rid
torque Vector3

BodySetEnableContinuousCollisionDetection(Rid, bool)

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.

public void BodySetEnableContinuousCollisionDetection(Rid body, bool enable)

Parameters

body Rid
enable bool

BodySetForceIntegrationCallback(Rid, Callable, Variant)

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

The function callable will be called every physics tick, before the standard force integration (see BodySetOmitForceIntegration(Rid, bool)). 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 PhysicsDirectBodyState3D, used to retrieve and modify the body's state,

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

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

public void BodySetForceIntegrationCallback(Rid body, Callable callable, Variant userdata = default)

Parameters

body Rid
callable Callable
userdata Variant

BodySetMaxContactsReported(Rid, int)

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.

public void BodySetMaxContactsReported(Rid body, int amount)

Parameters

body Rid
amount int

BodySetMode(Rid, BodyMode)

Sets the body mode, from one of the PhysicsServer3D.BodyMode constants.

public void BodySetMode(Rid body, PhysicsServer3D.BodyMode mode)

Parameters

body Rid
mode PhysicsServer3D.BodyMode

BodySetOmitForceIntegration(Rid, 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(Rid, Callable, Variant) can be used to manually update the linear and angular velocity instead.

This method is called when the property CustomIntegrator is set.

public void BodySetOmitForceIntegration(Rid body, bool enable)

Parameters

body Rid
enable bool

BodySetParam(Rid, BodyParameter, Variant)

Sets a body parameter. A list of available parameters is on the PhysicsServer3D.BodyParameter constants.

public void BodySetParam(Rid body, PhysicsServer3D.BodyParameter param, Variant value)

Parameters

body Rid
param PhysicsServer3D.BodyParameter
value Variant

BodySetRayPickable(Rid, bool)

Sets the body pickable with rays if enable is set.

public void BodySetRayPickable(Rid body, bool enable)

Parameters

body Rid
enable bool

BodySetShape(Rid, int, Rid)

Substitutes a given body shape by another. The old shape is selected by its index, the new one by its Rid.

public void BodySetShape(Rid body, int shapeIdx, Rid shape)

Parameters

body Rid
shapeIdx int
shape Rid

BodySetShapeDisabled(Rid, int, bool)

public void BodySetShapeDisabled(Rid body, int shapeIdx, bool disabled)

Parameters

body Rid
shapeIdx int
disabled bool

BodySetShapeTransform(Rid, int, Transform3D)

Sets the transform matrix for a body shape.

public void BodySetShapeTransform(Rid body, int shapeIdx, Transform3D transform)

Parameters

body Rid
shapeIdx int
transform Transform3D

BodySetSpace(Rid, Rid)

Assigns a space to the body (see SpaceCreate()).

public void BodySetSpace(Rid body, Rid space)

Parameters

body Rid
space Rid

BodySetState(Rid, BodyState, Variant)

Sets a body state (see PhysicsServer3D.BodyState constants).

public void BodySetState(Rid body, PhysicsServer3D.BodyState state, Variant value)

Parameters

body Rid
state PhysicsServer3D.BodyState
value Variant

BodySetStateSyncCallback(Rid, Callable)

Sets the body's state synchronization callback function to callable. Use an empty Callable (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 PhysicsDirectBodyState3D, used to retrieve the body's state.

public void BodySetStateSyncCallback(Rid body, Callable callable)

Parameters

body Rid
callable Callable

BodyTestMotion(Rid, PhysicsTestMotionParameters3D, PhysicsTestMotionResult3D)

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.

public bool BodyTestMotion(Rid body, PhysicsTestMotionParameters3D parameters, PhysicsTestMotionResult3D result = null)

Parameters

body Rid
parameters PhysicsTestMotionParameters3D
result PhysicsTestMotionResult3D

Returns

bool

BoxShapeCreate()

public Rid BoxShapeCreate()

Returns

Rid

CapsuleShapeCreate()

public Rid CapsuleShapeCreate()

Returns

Rid

ConcavePolygonShapeCreate()

public Rid ConcavePolygonShapeCreate()

Returns

Rid

ConeTwistJointGetParam(Rid, ConeTwistJointParam)

Gets a cone_twist_joint parameter (see PhysicsServer3D.ConeTwistJointParam constants).

public float ConeTwistJointGetParam(Rid joint, PhysicsServer3D.ConeTwistJointParam param)

Parameters

joint Rid
param PhysicsServer3D.ConeTwistJointParam

Returns

float

ConeTwistJointSetParam(Rid, ConeTwistJointParam, float)

Sets a cone_twist_joint parameter (see PhysicsServer3D.ConeTwistJointParam constants).

public void ConeTwistJointSetParam(Rid joint, PhysicsServer3D.ConeTwistJointParam param, float value)

Parameters

joint Rid
param PhysicsServer3D.ConeTwistJointParam
value float

ConvexPolygonShapeCreate()

public Rid ConvexPolygonShapeCreate()

Returns

Rid

CustomShapeCreate()

public Rid CustomShapeCreate()

Returns

Rid

CylinderShapeCreate()

public Rid CylinderShapeCreate()

Returns

Rid

FreeRid(Rid)

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.

public void FreeRid(Rid rid)

Parameters

rid Rid

Generic6DofJointGetFlag(Rid, Axis, G6DofJointAxisFlag)

Returns the value of a generic 6DOF joint flag. See PhysicsServer3D.G6DofJointAxisFlag for the list of available flags.

public bool Generic6DofJointGetFlag(Rid joint, Vector3.Axis axis, PhysicsServer3D.G6DofJointAxisFlag flag)

Parameters

joint Rid
axis Vector3.Axis
flag PhysicsServer3D.G6DofJointAxisFlag

Returns

bool

Generic6DofJointGetParam(Rid, Axis, G6DofJointAxisParam)

Returns the value of a generic 6DOF joint parameter. See PhysicsServer3D.G6DofJointAxisParam for the list of available parameters.

public float Generic6DofJointGetParam(Rid joint, Vector3.Axis axis, PhysicsServer3D.G6DofJointAxisParam param)

Parameters

joint Rid
axis Vector3.Axis
param PhysicsServer3D.G6DofJointAxisParam

Returns

float

Generic6DofJointSetFlag(Rid, Axis, G6DofJointAxisFlag, bool)

Sets the value of a given generic 6DOF joint flag. See PhysicsServer3D.G6DofJointAxisFlag for the list of available flags.

public void Generic6DofJointSetFlag(Rid joint, Vector3.Axis axis, PhysicsServer3D.G6DofJointAxisFlag flag, bool enable)

Parameters

joint Rid
axis Vector3.Axis
flag PhysicsServer3D.G6DofJointAxisFlag
enable bool

Generic6DofJointSetParam(Rid, Axis, G6DofJointAxisParam, float)

Sets the value of a given generic 6DOF joint parameter. See PhysicsServer3D.G6DofJointAxisParam for the list of available parameters.

public void Generic6DofJointSetParam(Rid joint, Vector3.Axis axis, PhysicsServer3D.G6DofJointAxisParam param, float value)

Parameters

joint Rid
axis Vector3.Axis
param PhysicsServer3D.G6DofJointAxisParam
value float

GetProcessInfo(ProcessInfo)

Returns information about the current state of the 3D physics engine. See PhysicsServer3D.ProcessInfo for a list of available states.

public int GetProcessInfo(PhysicsServer3D.ProcessInfo processInfo)

Parameters

processInfo PhysicsServer3D.ProcessInfo

Returns

int

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HeightmapShapeCreate()

public Rid HeightmapShapeCreate()

Returns

Rid

HingeJointGetFlag(Rid, HingeJointFlag)

Gets a hinge_joint flag (see PhysicsServer3D.HingeJointFlag constants).

public bool HingeJointGetFlag(Rid joint, PhysicsServer3D.HingeJointFlag flag)

Parameters

joint Rid
flag PhysicsServer3D.HingeJointFlag

Returns

bool

HingeJointGetParam(Rid, HingeJointParam)

Gets a hinge_joint parameter (see PhysicsServer3D.HingeJointParam).

public float HingeJointGetParam(Rid joint, PhysicsServer3D.HingeJointParam param)

Parameters

joint Rid
param PhysicsServer3D.HingeJointParam

Returns

float

HingeJointSetFlag(Rid, HingeJointFlag, bool)

Sets a hinge_joint flag (see PhysicsServer3D.HingeJointFlag constants).

public void HingeJointSetFlag(Rid joint, PhysicsServer3D.HingeJointFlag flag, bool enabled)

Parameters

joint Rid
flag PhysicsServer3D.HingeJointFlag
enabled bool

HingeJointSetParam(Rid, HingeJointParam, float)

Sets a hinge_joint parameter (see PhysicsServer3D.HingeJointParam constants).

public void HingeJointSetParam(Rid joint, PhysicsServer3D.HingeJointParam param, float value)

Parameters

joint Rid
param PhysicsServer3D.HingeJointParam
value float

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

JointClear(Rid)

public void JointClear(Rid joint)

Parameters

joint Rid

JointCreate()

public Rid JointCreate()

Returns

Rid

JointDisableCollisionsBetweenBodies(Rid, bool)

Sets whether the bodies attached to the Joint3D will collide with each other.

public void JointDisableCollisionsBetweenBodies(Rid joint, bool disable)

Parameters

joint Rid
disable bool

JointGetSolverPriority(Rid)

Gets the priority value of the Joint3D.

public int JointGetSolverPriority(Rid joint)

Parameters

joint Rid

Returns

int

JointGetType(Rid)

Returns the type of the Joint3D.

public PhysicsServer3D.JointType JointGetType(Rid joint)

Parameters

joint Rid

Returns

PhysicsServer3D.JointType

JointIsDisabledCollisionsBetweenBodies(Rid)

Returns whether the bodies attached to the Joint3D will collide with each other.

public bool JointIsDisabledCollisionsBetweenBodies(Rid joint)

Parameters

joint Rid

Returns

bool

JointMakeConeTwist(Rid, Rid, Transform3D, Rid, Transform3D)

public void JointMakeConeTwist(Rid joint, Rid bodyA, Transform3D localRefA, Rid bodyB, Transform3D localRefB)

Parameters

joint Rid
bodyA Rid
localRefA Transform3D
bodyB Rid
localRefB Transform3D

JointMakeGeneric6Dof(Rid, Rid, Transform3D, Rid, Transform3D)

Make the joint a generic six degrees of freedom (6DOF) joint. Use Generic6DofJointSetFlag(Rid, Axis, G6DofJointAxisFlag, bool) and Generic6DofJointSetParam(Rid, Axis, G6DofJointAxisParam, float) to set the joint's flags and parameters respectively.

public void JointMakeGeneric6Dof(Rid joint, Rid bodyA, Transform3D localRefA, Rid bodyB, Transform3D localRefB)

Parameters

joint Rid
bodyA Rid
localRefA Transform3D
bodyB Rid
localRefB Transform3D

JointMakeHinge(Rid, Rid, Transform3D, Rid, Transform3D)

public void JointMakeHinge(Rid joint, Rid bodyA, Transform3D hingeA, Rid bodyB, Transform3D hingeB)

Parameters

joint Rid
bodyA Rid
hingeA Transform3D
bodyB Rid
hingeB Transform3D

JointMakePin(Rid, Rid, Vector3, Rid, Vector3)

public void JointMakePin(Rid joint, Rid bodyA, Vector3 localA, Rid bodyB, Vector3 localB)

Parameters

joint Rid
bodyA Rid
localA Vector3
bodyB Rid
localB Vector3

JointMakeSlider(Rid, Rid, Transform3D, Rid, Transform3D)

public void JointMakeSlider(Rid joint, Rid bodyA, Transform3D localRefA, Rid bodyB, Transform3D localRefB)

Parameters

joint Rid
bodyA Rid
localRefA Transform3D
bodyB Rid
localRefB Transform3D

JointSetSolverPriority(Rid, int)

Sets the priority value of the Joint3D.

public void JointSetSolverPriority(Rid joint, int priority)

Parameters

joint Rid
priority int

PinJointGetLocalA(Rid)

Returns position of the joint in the local space of body a of the joint.

public Vector3 PinJointGetLocalA(Rid joint)

Parameters

joint Rid

Returns

Vector3

PinJointGetLocalB(Rid)

Returns position of the joint in the local space of body b of the joint.

public Vector3 PinJointGetLocalB(Rid joint)

Parameters

joint Rid

Returns

Vector3

PinJointGetParam(Rid, PinJointParam)

Gets a pin_joint parameter (see PhysicsServer3D.PinJointParam constants).

public float PinJointGetParam(Rid joint, PhysicsServer3D.PinJointParam param)

Parameters

joint Rid
param PhysicsServer3D.PinJointParam

Returns

float

PinJointSetLocalA(Rid, Vector3)

Sets position of the joint in the local space of body a of the joint.

public void PinJointSetLocalA(Rid joint, Vector3 localA)

Parameters

joint Rid
localA Vector3

PinJointSetLocalB(Rid, Vector3)

Sets position of the joint in the local space of body b of the joint.

public void PinJointSetLocalB(Rid joint, Vector3 localB)

Parameters

joint Rid
localB Vector3

PinJointSetParam(Rid, PinJointParam, float)

Sets a pin_joint parameter (see PhysicsServer3D.PinJointParam constants).

public void PinJointSetParam(Rid joint, PhysicsServer3D.PinJointParam param, float value)

Parameters

joint Rid
param PhysicsServer3D.PinJointParam
value float

SeparationRayShapeCreate()

public Rid SeparationRayShapeCreate()

Returns

Rid

SetActive(bool)

Activates or deactivates the 3D physics engine.

public void SetActive(bool active)

Parameters

active bool

ShapeGetData(Rid)

Returns the shape data.

public Variant ShapeGetData(Rid shape)

Parameters

shape Rid

Returns

Variant

ShapeGetMargin(Rid)

Returns the collision margin for the shape.

Note: This is not used in Godot Physics, so will always return 0.

public float ShapeGetMargin(Rid shape)

Parameters

shape Rid

Returns

float

ShapeGetType(Rid)

Returns the type of shape (see PhysicsServer3D.ShapeType constants).

public PhysicsServer3D.ShapeType ShapeGetType(Rid shape)

Parameters

shape Rid

Returns

PhysicsServer3D.ShapeType

ShapeSetData(Rid, Variant)

Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created ShapeGetType(Rid).

public void ShapeSetData(Rid shape, Variant data)

Parameters

shape Rid
data Variant

ShapeSetMargin(Rid, float)

Sets the collision margin for the shape.

Note: This is not used in Godot Physics.

public void ShapeSetMargin(Rid shape, float margin)

Parameters

shape Rid
margin float

SliderJointGetParam(Rid, SliderJointParam)

Gets a slider_joint parameter (see PhysicsServer3D.SliderJointParam constants).

public float SliderJointGetParam(Rid joint, PhysicsServer3D.SliderJointParam param)

Parameters

joint Rid
param PhysicsServer3D.SliderJointParam

Returns

float

SliderJointSetParam(Rid, SliderJointParam, float)

Gets a slider_joint parameter (see PhysicsServer3D.SliderJointParam constants).

public void SliderJointSetParam(Rid joint, PhysicsServer3D.SliderJointParam param, float value)

Parameters

joint Rid
param PhysicsServer3D.SliderJointParam
value float

SoftBodyAddCollisionException(Rid, Rid)

Adds the given body to the list of bodies exempt from collisions.

public void SoftBodyAddCollisionException(Rid body, Rid bodyB)

Parameters

body Rid
bodyB Rid

SoftBodyCreate()

Creates a new soft body and returns its internal Rid.

public Rid SoftBodyCreate()

Returns

Rid

SoftBodyGetBounds(Rid)

Returns the bounds of the given soft body in global coordinates.

public Aabb SoftBodyGetBounds(Rid body)

Parameters

body Rid

Returns

Aabb

SoftBodyGetCollisionLayer(Rid)

Returns the physics layer or layers that the given soft body belongs to.

public uint SoftBodyGetCollisionLayer(Rid body)

Parameters

body Rid

Returns

uint

SoftBodyGetCollisionMask(Rid)

Returns the physics layer or layers that the given soft body can collide with.

public uint SoftBodyGetCollisionMask(Rid body)

Parameters

body Rid

Returns

uint

SoftBodyGetDampingCoefficient(Rid)

Returns the damping coefficient of the given soft body.

public float SoftBodyGetDampingCoefficient(Rid body)

Parameters

body Rid

Returns

float

SoftBodyGetDragCoefficient(Rid)

Returns the drag coefficient of the given soft body.

public float SoftBodyGetDragCoefficient(Rid body)

Parameters

body Rid

Returns

float

SoftBodyGetLinearStiffness(Rid)

Returns the linear stiffness of the given soft body.

public float SoftBodyGetLinearStiffness(Rid body)

Parameters

body Rid

Returns

float

SoftBodyGetPointGlobalPosition(Rid, int)

Returns the current position of the given soft body point in global coordinates.

public Vector3 SoftBodyGetPointGlobalPosition(Rid body, int pointIndex)

Parameters

body Rid
pointIndex int

Returns

Vector3

SoftBodyGetPressureCoefficient(Rid)

Returns the pressure coefficient of the given soft body.

public float SoftBodyGetPressureCoefficient(Rid body)

Parameters

body Rid

Returns

float

SoftBodyGetSimulationPrecision(Rid)

Returns the simulation precision of the given soft body.

public int SoftBodyGetSimulationPrecision(Rid body)

Parameters

body Rid

Returns

int

SoftBodyGetSpace(Rid)

Returns the Rid of the space assigned to the given soft body.

public Rid SoftBodyGetSpace(Rid body)

Parameters

body Rid

Returns

Rid

SoftBodyGetState(Rid, BodyState)

Returns the given soft body state (see PhysicsServer3D.BodyState constants).

Note: Godot's default physics implementation does not support LinearVelocity, AngularVelocity, Sleeping, or CanSleep.

public Variant SoftBodyGetState(Rid body, PhysicsServer3D.BodyState state)

Parameters

body Rid
state PhysicsServer3D.BodyState

Returns

Variant

SoftBodyGetTotalMass(Rid)

Returns the total mass assigned to the given soft body.

public float SoftBodyGetTotalMass(Rid body)

Parameters

body Rid

Returns

float

SoftBodyIsPointPinned(Rid, int)

Returns whether the given soft body point is pinned.

public bool SoftBodyIsPointPinned(Rid body, int pointIndex)

Parameters

body Rid
pointIndex int

Returns

bool

SoftBodyMovePoint(Rid, int, Vector3)

Moves the given soft body point to a position in global coordinates.

public void SoftBodyMovePoint(Rid body, int pointIndex, Vector3 globalPosition)

Parameters

body Rid
pointIndex int
globalPosition Vector3

SoftBodyPinPoint(Rid, int, bool)

Pins or unpins the given soft body point based on the value of pin.

Note: Pinning a point effectively makes it kinematic, preventing it from being affected by forces, but you can still move it using SoftBodyMovePoint(Rid, int, Vector3).

public void SoftBodyPinPoint(Rid body, int pointIndex, bool pin)

Parameters

body Rid
pointIndex int
pin bool

SoftBodyRemoveAllPinnedPoints(Rid)

Unpins all points of the given soft body.

public void SoftBodyRemoveAllPinnedPoints(Rid body)

Parameters

body Rid

SoftBodyRemoveCollisionException(Rid, Rid)

Removes the given body from the list of bodies exempt from collisions.

public void SoftBodyRemoveCollisionException(Rid body, Rid bodyB)

Parameters

body Rid
bodyB Rid

SoftBodySetCollisionLayer(Rid, uint)

Sets the physics layer or layers the given soft body belongs to.

public void SoftBodySetCollisionLayer(Rid body, uint layer)

Parameters

body Rid
layer uint

SoftBodySetCollisionMask(Rid, uint)

Sets the physics layer or layers the given soft body can collide with.

public void SoftBodySetCollisionMask(Rid body, uint mask)

Parameters

body Rid
mask uint

SoftBodySetDampingCoefficient(Rid, float)

Sets the damping coefficient of the given soft body. Higher values will slow down the body more noticeably when forces are applied.

public void SoftBodySetDampingCoefficient(Rid body, float dampingCoefficient)

Parameters

body Rid
dampingCoefficient float

SoftBodySetDragCoefficient(Rid, float)

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.

public void SoftBodySetDragCoefficient(Rid body, float dragCoefficient)

Parameters

body Rid
dragCoefficient float

SoftBodySetLinearStiffness(Rid, float)

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

public void SoftBodySetLinearStiffness(Rid body, float stiffness)

Parameters

body Rid
stiffness float

SoftBodySetMesh(Rid, Rid)

Sets the mesh of the given soft body.

public void SoftBodySetMesh(Rid body, Rid mesh)

Parameters

body Rid
mesh Rid

SoftBodySetPressureCoefficient(Rid, float)

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.

public void SoftBodySetPressureCoefficient(Rid body, float pressureCoefficient)

Parameters

body Rid
pressureCoefficient float

SoftBodySetRayPickable(Rid, bool)

Sets whether the given soft body will be pickable when using object picking.

public void SoftBodySetRayPickable(Rid body, bool enable)

Parameters

body Rid
enable bool

SoftBodySetSimulationPrecision(Rid, int)

Sets the simulation precision of the given soft body. Increasing this value will improve the resulting simulation, but can affect performance. Use with care.

public void SoftBodySetSimulationPrecision(Rid body, int simulationPrecision)

Parameters

body Rid
simulationPrecision int

SoftBodySetSpace(Rid, Rid)

Assigns a space to the given soft body (see SpaceCreate()).

public void SoftBodySetSpace(Rid body, Rid space)

Parameters

body Rid
space Rid

SoftBodySetState(Rid, BodyState, Variant)

Sets the given body state for the given body (see PhysicsServer3D.BodyState constants).

Note: Godot's default physics implementation does not support LinearVelocity, AngularVelocity, Sleeping, or CanSleep.

public void SoftBodySetState(Rid body, PhysicsServer3D.BodyState state, Variant variant)

Parameters

body Rid
state PhysicsServer3D.BodyState
variant Variant

SoftBodySetTotalMass(Rid, float)

Sets the total mass for the given soft body.

public void SoftBodySetTotalMass(Rid body, float totalMass)

Parameters

body Rid
totalMass float

SoftBodySetTransform(Rid, Transform3D)

Sets the global transform of the given soft body.

public void SoftBodySetTransform(Rid body, Transform3D transform)

Parameters

body Rid
transform Transform3D

SoftBodyUpdateRenderingServer(Rid, PhysicsServer3DRenderingServerHandler)

Requests that the physics server updates the rendering server with the latest positions of the given soft body's points through the renderingServerHandler interface.

public void SoftBodyUpdateRenderingServer(Rid body, PhysicsServer3DRenderingServerHandler renderingServerHandler)

Parameters

body Rid
renderingServerHandler PhysicsServer3DRenderingServerHandler

SpaceCreate()

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 AreaSetSpace(Rid, Rid), or to a body with BodySetSpace(Rid, Rid).

public Rid SpaceCreate()

Returns

Rid

SpaceGetDirectState(Rid)

Returns the state of a space, a PhysicsDirectSpaceState3D. This object can be used to make collision/intersection queries.

public PhysicsDirectSpaceState3D SpaceGetDirectState(Rid space)

Parameters

space Rid

Returns

PhysicsDirectSpaceState3D

SpaceGetParam(Rid, SpaceParameter)

Returns the value of a space parameter.

public float SpaceGetParam(Rid space, PhysicsServer3D.SpaceParameter param)

Parameters

space Rid
param PhysicsServer3D.SpaceParameter

Returns

float

SpaceIsActive(Rid)

Returns whether the space is active.

public bool SpaceIsActive(Rid space)

Parameters

space Rid

Returns

bool

SpaceSetActive(Rid, bool)

Marks a space as active. It will not have an effect, unless it is assigned to an area or body.

public void SpaceSetActive(Rid space, bool active)

Parameters

space Rid
active bool

SpaceSetParam(Rid, SpaceParameter, float)

Sets the value for a space parameter. A list of available parameters is on the PhysicsServer3D.SpaceParameter constants.

public void SpaceSetParam(Rid space, PhysicsServer3D.SpaceParameter param, float value)

Parameters

space Rid
param PhysicsServer3D.SpaceParameter
value float

SphereShapeCreate()

public Rid SphereShapeCreate()

Returns

Rid

WorldBoundaryShapeCreate()

public Rid WorldBoundaryShapeCreate()

Returns

Rid