Server interface for low-level physics access.
PhysicsServer3D is the server responsible for all 3D physics. It can create many kinds of physics objects, but does not insert them on the node tree.
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.
Assigns the area to a descendant of [Object], so it can exist in the node tree.
Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
Creates an [Area3D].
Returns the physics layer or layers an area belongs to.
Returns the physics layer or layers an area can contact with.
Gets the instance ID of the object the area is assigned to.
Returns an area parameter value. A list of available parameters is on the [enum AreaParameter] constants.
Returns the [RID] of the nth shape of an area.
Returns the number of shapes assigned to an area.
Returns the transform matrix of a shape within an area.
Returns the space assigned to the area.
Returns the transform matrix for an area.
Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
Assigns the area to one or many physics layers.
Sets which physics layers the area will monitor.
Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters:
1: [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED], depending on whether the object entered or exited the area.
2: [RID] of the object that entered/exited the area.
3: Instance ID of the object that entered/exited the area.
4: The shape index of the object that entered/exited the area.
5: The shape index of the area where the object entered/exited.
Sets the value for an area parameter. A list of available parameters is on the [enum AreaParameter] constants.
Sets object pickable with rays.
Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID].
Sets the transform matrix for an area shape.
Assigns a space to the area.
Sets the transform matrix for an area.
Adds a body to the list of bodies exempt from collisions.
Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with [code]body_set_constant_force(body, Vector3(0, 0, 0))[/code].
This is equivalent to using [method body_add_constant_force] at the body's center of mass.
Adds a constant positioned force to the body that keeps being applied over time until cleared with [code]body_set_constant_force(body, Vector3(0, 0, 0))[/code].
[param position] is the offset from the body origin in global coordinates.
Adds a constant rotational force without affecting position that keeps being applied over time until cleared with [code]body_set_constant_torque(body, Vector3(0, 0, 0))[/code].
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.
Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
This is equivalent to using [method body_apply_force] at the body's center of mass.
Applies a directional impulse without affecting rotation.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
This is equivalent to using [method body_apply_impulse] at the body's center of mass.
Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
[param position] is the offset from the body origin in global coordinates.
Applies a positioned impulse to the body.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
[param position] is the offset from the body origin in global coordinates.
Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
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).
Assigns the area to a descendant of [Object], so it can exist in the node tree.
Removes all shapes from a body.
Returns the physics layer or layers a body belongs to.
Returns the physics layer or layers a body can collide with.
Returns the body's collision priority.
Returns the body's total constant positional forces applied during each physics update.
See [method body_add_constant_force] and [method body_add_constant_central_force].
Returns the body's total constant rotational forces applied during each physics update.
See [method body_add_constant_torque].
Returns the [PhysicsDirectBodyState3D] of the body. Returns [code]null[/code] if the body is destroyed or removed from the physics space.
Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported].
Returns the body mode.
Gets the instance ID of the object the area is assigned to.
Returns the value of a body parameter. A list of available parameters is on the [enum BodyParameter] constants.
Returns the [RID] of the nth shape of a body.
Returns the number of shapes assigned to a body.
Returns the transform matrix of a body shape.
Returns the [RID] of the space assigned to a body.
Returns a body state.
If [code]true[/code], the continuous collision detection mode is enabled.
Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
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.
Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
Restores the default inertia and center of mass based on shapes to cancel any custom values previously set using [method body_set_param].
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.
Sets the physics layer or layers a body belongs to.
Sets the physics layer or layers a body can collide with.
Sets the body's collision priority.
Sets the body's total constant positional forces applied during each physics update.
See [method body_add_constant_force] and [method body_add_constant_central_force].
Sets the body's total constant rotational forces applied during each physics update.
See [method body_add_constant_torque].
If [code]true[/code], 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.
Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]).
The force integration function takes 2 arguments:
[code]state:[/code] [PhysicsDirectBodyState3D] used to retrieve and modify the body's state.
[code]userdata:[/code] Optional user data, if it was passed when calling [code]body_set_force_integration_callback[/code].
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.
Sets the body mode, from one of the [enum BodyMode] constants.
Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
Sets a body parameter. A list of available parameters is on the [enum BodyParameter] constants.
Sets the body pickable with rays if [param enable] is set.
Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID].
Sets the transform matrix for a body shape.
Assigns a space to the body (see [method space_create]).
Sets a body state (see [enum BodyState] constants).
Returns [code]true[/code] 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.
Gets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants).
Sets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants).
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.
Gets a generic_6_DOF_joint flag (see [enum G6DOFJointAxisFlag] constants).
Gets a generic_6_DOF_joint parameter (see [enum G6DOFJointAxisParam] constants).
Sets a generic_6_DOF_joint flag (see [enum G6DOFJointAxisFlag] constants).
Sets a generic_6_DOF_joint parameter (see [enum G6DOFJointAxisParam] constants).
Returns information about the current state of the 3D physics engine. See [enum ProcessInfo] for a list of available states.
Gets a hinge_joint flag (see [enum HingeJointFlag] constants).
Gets a hinge_joint parameter (see [enum HingeJointParam]).
Sets a hinge_joint flag (see [enum HingeJointFlag] constants).
Sets a hinge_joint parameter (see [enum HingeJointParam] constants).
Sets whether the bodies attached to the [Joint3D] will collide with each other.
Gets the priority value of the Joint3D.
Returns the type of the Joint3D.
Returns whether the bodies attached to the [Joint3D] will collide with each other.
Sets the priority value of the Joint3D.
Returns position of the joint in the local space of body a of the joint.
Returns position of the joint in the local space of body b of the joint.
Gets a pin_joint parameter (see [enum PinJointParam] constants).
Sets position of the joint in the local space of body a of the joint.
Sets position of the joint in the local space of body b of the joint.
Sets a pin_joint parameter (see [enum PinJointParam] constants).
Activates or deactivates the 3D physics engine.
Returns the shape data.
Returns the type of shape (see [enum ShapeType] constants).
Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type].
Gets a slider_joint parameter (see [enum SliderJointParam] constants).
Gets a slider_joint parameter (see [enum SliderJointParam] constants).
Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with [method area_set_space], or to a body with [method body_set_space].
Returns the state of a space, a [PhysicsDirectSpaceState3D]. This object can be used to make collision/intersection queries.
Returns the value of a space parameter.
Returns whether the space is active.
Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
Sets the value for a space parameter. A list of available parameters is on the [enum SpaceParameter] constants.
The [Joint3D] is a [PinJoint3D].
The [Joint3D] is a [HingeJoint3D].
The [Joint3D] is a [SliderJoint3D].
The [Joint3D] is a [ConeTwistJoint3D].
The [Joint3D] is a [Generic6DOFJoint3D].
Represents the size of the [enum JointType] enum.
The strength with which the pinned objects try to stay in positional relation to each other.
The higher, the stronger.
The strength with which the pinned objects try to stay in velocity relation to each other.
The higher, the stronger.
If above 0, this value is the maximum value for an impulse that this Joint3D puts on its ends.
The speed with which the two bodies get pulled together when they move in different directions.
The maximum rotation across the Hinge.
The minimum rotation across the Hinge.
The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
The lower this value, the more the rotation gets slowed down.
Target speed for the motor.
Maximum acceleration for the motor.
If [code]true[/code], the Hinge has a maximum and a minimum rotation.
If [code]true[/code], a motor turns the Hinge.
The maximum difference between the pivot points on their X axis before damping happens.
The minimum difference between the pivot points on their X axis before damping happens.
A factor applied to the movement across the slider axis once the limits get surpassed. The lower, the slower the movement.
The amount of restitution once the limits are surpassed. The lower, the more velocityenergy gets lost.
The amount of damping once the slider limits are surpassed.
A factor applied to the movement across the slider axis as long as the slider is in the limits. The lower, the slower the movement.
The amount of restitution inside the slider limits.
The amount of damping inside the slider limits.
A factor applied to the movement across axes orthogonal to the slider.
The amount of restitution when movement is across axes orthogonal to the slider.
The amount of damping when movement is across axes orthogonal to the slider.
The upper limit of rotation in the slider.
The lower limit of rotation in the slider.
A factor applied to the all rotation once the limit is surpassed.
The amount of restitution of the rotation when the limit is surpassed.
The amount of damping of the rotation when the limit is surpassed.
A factor that gets applied to the all rotation in the limits.
The amount of restitution of the rotation in the limits.
The amount of damping of the rotation in the limits.
A factor that gets applied to the all rotation across axes orthogonal to the slider.
The amount of restitution of the rotation across axes orthogonal to the slider.
The amount of damping of the rotation across axes orthogonal to the slider.
Represents the size of the [enum SliderJointParam] enum.
Swing is rotation from side to side, around the axis perpendicular to the twist axis.
The swing span defines, how much rotation will not get corrected along the swing axis.
Could be defined as looseness in the [ConeTwistJoint3D].
If below 0.05, this behavior is locked.
Twist is the rotation around the twist axis, this value defined how far the joint can twist.
Twist is locked if below 0.05.
The speed with which the swing or twist will take place.
The higher, the faster.
The ease with which the Joint3D twists, if it's too low, it takes more force to twist the joint.
Defines, how fast the swing- and twist-speed-difference on both sides gets synced.
The minimum difference between the pivot points' axes.
The maximum difference between the pivot points' axes.
A factor that gets applied to the movement across the axes. The lower, the slower the movement.
The amount of restitution on the axes movement. The lower, the more velocity-energy gets lost.
The amount of damping that happens at the linear motion across the axes.
The velocity that the joint's linear motor will attempt to reach.
The maximum force that the linear motor can apply while trying to reach the target velocity.
The minimum rotation in negative direction to break loose and rotate around the axes.
The minimum rotation in positive direction to break loose and rotate around the axes.
A factor that gets multiplied onto all rotations across the axes.
The amount of rotational damping across the axes. The lower, the more dampening occurs.
The amount of rotational restitution across the axes. The lower, the more restitution occurs.
The maximum amount of force that can occur, when rotating around the axes.
When correcting the crossing of limits in rotation across the axes, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower.
Target speed for the motor at the axes.
Maximum acceleration for the motor at the axes.
If set, linear motion is possible within the given limits.
If set, rotational motion is possible.
If set, there is a rotational motor across these axes.
If set, there is a linear motor on this axis that targets a specific velocity.
The [Shape3D] is a [WorldBoundaryShape3D].
The [Shape3D] is a [SeparationRayShape3D].
The [Shape3D] is a [SphereShape3D].
The [Shape3D] is a [BoxShape3D].
The [Shape3D] is a [CapsuleShape3D].
The [Shape3D] is a [CylinderShape3D].
The [Shape3D] is a [ConvexPolygonShape3D].
The [Shape3D] is a [ConcavePolygonShape3D].
The [Shape3D] is a [HeightMapShape3D].
The [Shape3D] is used internally for a soft body. Any attempt to create this kind of shape results in an error.
This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
Constant to set/get gravity override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
Constant to set/get gravity strength in an area.
Constant to set/get gravity vector/center in an area.
Constant to set/get whether the gravity vector of an area is a direction, or a center point.
Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by [constant AREA_PARAM_GRAVITY]. For example, on a planet 100 meters in radius with a surface gravity of 4.0 m/s², set the gravity to 4.0 and the unit distance to 100.0. The gravity will have falloff according to the inverse square law, so in the example, at 200 meters from the center the gravity will be 1.0 m/s² (twice the distance, 1/4th the gravity), at 50 meters it will be 16.0 m/s² (half the distance, 4x the gravity), and so on.
The above is true only when the unit distance is a positive number. When this is set to 0.0, the gravity will be constant regardless of distance.
Constant to set/get linear damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
Constant to set/get the linear damping factor of an area.
Constant to set/get angular damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
Constant to set/get the angular damping factor of an area.
Constant to set/get the priority (order of processing) of an area.
Constant to set/get the magnitude of area-specific wind force.
Constant to set/get the 3D vector that specifies the origin from which an area-specific wind blows.
Constant to set/get the 3D vector that specifies the direction in which an area-specific wind blows.
Constant to set/get the exponential rate at which wind force decreases with distance from its origin.
This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
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.
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.
This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
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.
Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path.
Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied.
Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces.
Constant to set/get a body's bounce factor.
Constant to set/get a body's friction.
Constant to set/get a body's mass.
Constant to set/get a body's inertia.
Constant to set/get a body's center of mass position in the body's local coordinate system.
Constant to set/get a body's gravity multiplier.
Constant to set/get a body's linear dampening mode. See [enum BodyDampMode] for possible values.
Constant to set/get a body's angular dampening mode. See [enum BodyDampMode] for possible values.
Constant to set/get a body's linear dampening factor.
Constant to set/get a body's angular dampening factor.
Represents the size of the [enum BodyParameter] enum.
The body's damping value is added to any value set in areas or the default value.
The body's damping value replaces any value set in areas or the default value.
Constant to set/get the current transform matrix of the body.
Constant to set/get the current linear velocity of the body.
Constant to set/get the current angular velocity of the body.
Constant to sleep/wake up a body, or to get whether it is sleeping.
Constant to set/get whether the body can sleep.
The value of the first parameter and area callback function receives, when an object enters one of its shapes.
The value of the first parameter and area callback function receives, when an object exits one of its shapes.
Constant to get the number of objects that are not sleeping.
Constant to get the number of possible collisions.
Constant to get the number of space regions where a collision could occur.
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
Constant to set/get the maximum distance a shape can be from another before they are considered separated and the contact is discarded.
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
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.
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.
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.
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.
Constant to set/get the number of solver iterations for contacts and constraints. The greater the number of iterations, the more accurate the collisions and constraints will be. However, a greater number of iterations requires more CPU power, which can decrease performance.