Class PhysicsServer3D
A server interface for low-level 3D physics access.
- Inheritance
-
PhysicsServer3D
- Derived
Remarks
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.
Methods
area_add_shape(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.
void area_add_shape(RID area, RID shape, Transform3D transform, bool disabled)
Parameters
area
RIDshape
RIDtransform
Transform3Ddisabled
bool
area_attach_object_instance_id(RID, int)
Assigns the area to a descendant of Object, so it can exist in the node tree.
void area_attach_object_instance_id(RID area, int id)
Parameters
area_clear_shapes(RID)
Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
void area_clear_shapes(RID area)
Parameters
area
RID
area_create
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 PhysicsServer3D.area_add_shape to add shapes to it, use PhysicsServer3D.area_set_transform to set its transform, and use PhysicsServer3D.area_set_space to add the area to a space. If you want the area to be detectable use PhysicsServer3D.area_set_monitorable.
RID area_create
area_get_collision_layer(RID)
Qualifiers: const
Returns the physics layer or layers an area belongs to.
int area_get_collision_layer(RID area)
Parameters
area
RID
area_get_collision_mask(RID)
Qualifiers: const
Returns the physics layer or layers an area can contact with.
int area_get_collision_mask(RID area)
Parameters
area
RID
area_get_object_instance_id(RID)
Qualifiers: const
Gets the instance ID of the object the area is assigned to.
int area_get_object_instance_id(RID area)
Parameters
area
RID
area_get_param(RID, int)
Qualifiers: const
Returns an area parameter value. A list of available parameters is on the AreaParameter constants.
Variant area_get_param(RID area, int param)
Parameters
area_get_shape(RID, int)
Qualifiers: const
Returns the RID of the nth shape of an area.
RID area_get_shape(RID area, int shape_idx)
Parameters
area_get_shape_count(RID)
Qualifiers: const
Returns the number of shapes assigned to an area.
int area_get_shape_count(RID area)
Parameters
area
RID
area_get_shape_transform(RID, int)
Qualifiers: const
Returns the transform matrix of a shape within an area.
Transform3D area_get_shape_transform(RID area, int shape_idx)
Parameters
area_get_space(RID)
Qualifiers: const
Returns the space assigned to the area.
RID area_get_space(RID area)
Parameters
area
RID
area_get_transform(RID)
Qualifiers: const
Returns the transform matrix for an area.
Transform3D area_get_transform(RID area)
Parameters
area
RID
area_remove_shape(RID, int)
Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
void area_remove_shape(RID area, int shape_idx)
Parameters
area_set_area_monitor_callback(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:
an integer
status
: either PhysicsServer3D.AREA_BODY_ADDED or PhysicsServer3D.AREA_BODY_REMOVED depending on whether the other area's shape entered or exited the area,an RID
area_rid
: the RID of the other area that entered or exited the area,an integer
instance_id
: theObjectID
attached to the other area,an integer
area_shape_idx
: the index of the shape of the other area that entered or exited the area,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.
void area_set_area_monitor_callback(RID area, Callable callback)
Parameters
area_set_collision_layer(RID, int)
Assigns the area to one or many physics layers.
void area_set_collision_layer(RID area, int layer)
Parameters
area_set_collision_mask(RID, int)
Sets which physics layers the area will monitor.
void area_set_collision_mask(RID area, int mask)
Parameters
area_set_monitor_callback(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:
an integer
status
: either PhysicsServer3D.AREA_BODY_ADDED or PhysicsServer3D.AREA_BODY_REMOVED depending on whether the other body shape entered or exited the area,an RID
body_rid
: the RID of the body that entered or exited the area,an integer
instance_id
: theObjectID
attached to the body,an integer
body_shape_idx
: the index of the shape of the body that entered or exited the area,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.
void area_set_monitor_callback(RID area, Callable callback)
Parameters
area_set_monitorable(RID, bool)
void area_set_monitorable(RID area, bool monitorable)
Parameters
area_set_param(RID, int, Variant)
Sets the value for an area parameter. A list of available parameters is on the AreaParameter constants.
void area_set_param(RID area, int param, Variant value)
Parameters
area_set_ray_pickable(RID, bool)
Sets object pickable with rays.
void area_set_ray_pickable(RID area, bool enable)
Parameters
area_set_shape(RID, int, RID)
Substitutes a given area shape by another. The old shape is selected by its index, the new one by its RID.
void area_set_shape(RID area, int shape_idx, RID shape)
Parameters
area_set_shape_disabled(RID, int, bool)
void area_set_shape_disabled(RID area, int shape_idx, bool disabled)
Parameters
area_set_shape_transform(RID, int, Transform3D)
Sets the transform matrix for an area shape.
void area_set_shape_transform(RID area, int shape_idx, Transform3D transform)
Parameters
area
RIDshape_idx
inttransform
Transform3D
area_set_space(RID, RID)
Assigns a space to the area.
void area_set_space(RID area, RID space)
Parameters
area_set_transform(RID, Transform3D)
Sets the transform matrix for an area.
void area_set_transform(RID area, Transform3D transform)
Parameters
area
RIDtransform
Transform3D
body_add_collision_exception(RID, RID)
Adds a body to the list of bodies exempt from collisions.
void body_add_collision_exception(RID body, RID excepted_body)
Parameters
body_add_constant_central_force(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 PhysicsServer3D.body_add_constant_force at the body's center of mass.
void body_add_constant_central_force(RID body, Vector3 force)
Parameters
body_add_constant_force(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.
void body_add_constant_force(RID body, Vector3 force, Vector3 position)
Parameters
body_add_constant_torque(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))
.
void body_add_constant_torque(RID body, Vector3 torque)
Parameters
body_add_shape(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.
void body_add_shape(RID body, RID shape, Transform3D transform, bool disabled)
Parameters
body
RIDshape
RIDtransform
Transform3Ddisabled
bool
body_apply_central_force(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 PhysicsServer3D.body_apply_force at the body's center of mass.
void body_apply_central_force(RID body, Vector3 force)
Parameters
body_apply_central_impulse(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 PhysicsServer3D.body_apply_impulse at the body's center of mass.
void body_apply_central_impulse(RID body, Vector3 impulse)
Parameters
body_apply_force(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.
void body_apply_force(RID body, Vector3 force, Vector3 position)
Parameters
body_apply_impulse(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.
void body_apply_impulse(RID body, Vector3 impulse, Vector3 position)
Parameters
body_apply_torque(RID, Vector3)
Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
void body_apply_torque(RID body, Vector3 torque)
Parameters
body_apply_torque_impulse(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).
void body_apply_torque_impulse(RID body, Vector3 impulse)
Parameters
body_attach_object_instance_id(RID, int)
Assigns the area to a descendant of Object, so it can exist in the node tree.
void body_attach_object_instance_id(RID body, int id)
Parameters
body_clear_shapes(RID)
Removes all shapes from a body.
void body_clear_shapes(RID body)
Parameters
body
RID
body_create
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 PhysicsServer3D.BODY_MODE_RIGID.
Use PhysicsServer3D.body_add_shape to add shapes to it, use PhysicsServer3D.body_set_state to set its transform, and use PhysicsServer3D.body_set_space to add the body to a space.
RID body_create
body_get_collision_layer(RID)
Qualifiers: const
Returns the physics layer or layers a body belongs to.
int body_get_collision_layer(RID body)
Parameters
body
RID
body_get_collision_mask(RID)
Qualifiers: const
Returns the physics layer or layers a body can collide with.
int body_get_collision_mask(RID body)
Parameters
body
RID
body_get_collision_priority(RID)
Qualifiers: const
Returns the body's collision priority.
float body_get_collision_priority(RID body)
Parameters
body
RID
body_get_constant_force(RID)
Qualifiers: const
Returns the body's total constant positional forces applied during each physics update.
See PhysicsServer3D.body_add_constant_force and PhysicsServer3D.body_add_constant_central_force.
Vector3 body_get_constant_force(RID body)
Parameters
body
RID
body_get_constant_torque(RID)
Qualifiers: const
Returns the body's total constant rotational forces applied during each physics update.
See PhysicsServer3D.body_add_constant_torque.
Vector3 body_get_constant_torque(RID body)
Parameters
body
RID
body_get_direct_state(RID)
Returns the PhysicsDirectBodyState3D of the body. Returns null
if the body is destroyed or removed from the physics space.
PhysicsDirectBodyState3D body_get_direct_state(RID body)
Parameters
body
RID
body_get_max_contacts_reported(RID)
Qualifiers: const
Returns the maximum contacts that can be reported. See PhysicsServer3D.body_set_max_contacts_reported.
int body_get_max_contacts_reported(RID body)
Parameters
body
RID
body_get_mode(RID)
Qualifiers: const
Returns the body mode.
int body_get_mode(RID body)
Parameters
body
RID
body_get_object_instance_id(RID)
Qualifiers: const
Gets the instance ID of the object the area is assigned to.
int body_get_object_instance_id(RID body)
Parameters
body
RID
body_get_param(RID, int)
Qualifiers: const
Returns the value of a body parameter. A list of available parameters is on the BodyParameter constants.
Variant body_get_param(RID body, int param)
Parameters
body_get_shape(RID, int)
Qualifiers: const
Returns the RID of the nth shape of a body.
RID body_get_shape(RID body, int shape_idx)
Parameters
body_get_shape_count(RID)
Qualifiers: const
Returns the number of shapes assigned to a body.
int body_get_shape_count(RID body)
Parameters
body
RID
body_get_shape_transform(RID, int)
Qualifiers: const
Returns the transform matrix of a body shape.
Transform3D body_get_shape_transform(RID body, int shape_idx)
Parameters
body_get_space(RID)
Qualifiers: const
Returns the RID of the space assigned to a body.
RID body_get_space(RID body)
Parameters
body
RID
body_get_state(RID, int)
Qualifiers: const
Returns a body state.
Variant body_get_state(RID body, int state)
Parameters
body_is_axis_locked(RID, int)
Qualifiers: const
bool body_is_axis_locked(RID body, int axis)
Parameters
body_is_continuous_collision_detection_enabled(RID)
Qualifiers: const
If true
, the continuous collision detection mode is enabled.
bool body_is_continuous_collision_detection_enabled(RID body)
Parameters
body
RID
body_is_omitting_force_integration(RID)
Qualifiers: const
Returns true
if the body is omitting the standard force integration. See PhysicsServer3D.body_set_omit_force_integration.
bool body_is_omitting_force_integration(RID body)
Parameters
body
RID
body_remove_collision_exception(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.
void body_remove_collision_exception(RID body, RID excepted_body)
Parameters
body_remove_shape(RID, int)
Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
void body_remove_shape(RID body, int shape_idx)
Parameters
body_reset_mass_properties(RID)
Restores the default inertia and center of mass based on shapes to cancel any custom values previously set using PhysicsServer3D.body_set_param.
void body_reset_mass_properties(RID body)
Parameters
body
RID
body_set_axis_lock(RID, int, bool)
void body_set_axis_lock(RID body, int axis, bool lock)
Parameters
body_set_axis_velocity(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.
void body_set_axis_velocity(RID body, Vector3 axis_velocity)
Parameters
body_set_collision_layer(RID, int)
Sets the physics layer or layers a body belongs to.
void body_set_collision_layer(RID body, int layer)
Parameters
body_set_collision_mask(RID, int)
Sets the physics layer or layers a body can collide with.
void body_set_collision_mask(RID body, int mask)
Parameters
body_set_collision_priority(RID, float)
Sets the body's collision priority.
void body_set_collision_priority(RID body, float priority)
Parameters
body_set_constant_force(RID, Vector3)
Sets the body's total constant positional forces applied during each physics update.
See PhysicsServer3D.body_add_constant_force and PhysicsServer3D.body_add_constant_central_force.
void body_set_constant_force(RID body, Vector3 force)
Parameters
body_set_constant_torque(RID, Vector3)
Sets the body's total constant rotational forces applied during each physics update.
See PhysicsServer3D.body_add_constant_torque.
void body_set_constant_torque(RID body, Vector3 torque)
Parameters
body_set_enable_continuous_collision_detection(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.
void body_set_enable_continuous_collision_detection(RID body, bool enable)
Parameters
body_set_force_integration_callback(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 PhysicsServer3D.body_set_omit_force_integration). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
If userdata
is not null
, the function callable
must take the following two parameters:
state
: a PhysicsDirectBodyState3D, used to retrieve and modify the body's state,userdata
: a Variant; its value will be theuserdata
passed into this method.
If userdata
is null
, then callable
must take only the state
parameter.
void body_set_force_integration_callback(RID body, Callable callable, Variant userdata)
Parameters
body_set_max_contacts_reported(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.
void body_set_max_contacts_reported(RID body, int amount)
Parameters
body_set_mode(RID, int)
Sets the body mode, from one of the BodyMode constants.
void body_set_mode(RID body, int mode)
Parameters
body_set_omit_force_integration(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, PhysicsServer3D.body_set_force_integration_callback can be used to manually update the linear and angular velocity instead.
This method is called when the property custom_integrator is set.
void body_set_omit_force_integration(RID body, bool enable)
Parameters
body_set_param(RID, int, Variant)
Sets a body parameter. A list of available parameters is on the BodyParameter constants.
void body_set_param(RID body, int param, Variant value)
Parameters
body_set_ray_pickable(RID, bool)
Sets the body pickable with rays if enable
is set.
void body_set_ray_pickable(RID body, bool enable)
Parameters
body_set_shape(RID, int, RID)
Substitutes a given body shape by another. The old shape is selected by its index, the new one by its RID.
void body_set_shape(RID body, int shape_idx, RID shape)
Parameters
body_set_shape_disabled(RID, int, bool)
void body_set_shape_disabled(RID body, int shape_idx, bool disabled)
Parameters
body_set_shape_transform(RID, int, Transform3D)
Sets the transform matrix for a body shape.
void body_set_shape_transform(RID body, int shape_idx, Transform3D transform)
Parameters
body
RIDshape_idx
inttransform
Transform3D
body_set_space(RID, RID)
Assigns a space to the body (see space_create).
void body_set_space(RID body, RID space)
Parameters
body_set_state(RID, int, Variant)
Sets a body state (see BodyState constants).
void body_set_state(RID body, int state, Variant value)
Parameters
body_set_state_sync_callback(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:
state
: a PhysicsDirectBodyState3D, used to retrieve the body's state.
void body_set_state_sync_callback(RID body, Callable callable)
Parameters
body_test_motion(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.
bool body_test_motion(RID body, PhysicsTestMotionParameters3D parameters, PhysicsTestMotionResult3D result)
Parameters
body
RIDparameters
PhysicsTestMotionParameters3Dresult
PhysicsTestMotionResult3D
box_shape_create
RID box_shape_create
capsule_shape_create
RID capsule_shape_create
concave_polygon_shape_create
RID concave_polygon_shape_create
cone_twist_joint_get_param(RID, int)
Qualifiers: const
Gets a cone_twist_joint parameter (see ConeTwistJointParam constants).
float cone_twist_joint_get_param(RID joint, int param)
Parameters
cone_twist_joint_set_param(RID, int, float)
Sets a cone_twist_joint parameter (see ConeTwistJointParam constants).
void cone_twist_joint_set_param(RID joint, int param, float value)
Parameters
convex_polygon_shape_create
RID convex_polygon_shape_create
custom_shape_create
RID custom_shape_create
cylinder_shape_create
RID cylinder_shape_create
free_rid(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.
void free_rid(RID rid)
Parameters
rid
RID
generic_6dof_joint_get_flag(RID, int, int)
Qualifiers: const
Returns the value of a generic 6DOF joint flag. See G6DOFJointAxisFlag for the list of available flags.
bool generic_6dof_joint_get_flag(RID joint, int axis, int flag)
Parameters
generic_6dof_joint_get_param(RID, int, int)
Qualifiers: const
Returns the value of a generic 6DOF joint parameter. See G6DOFJointAxisParam for the list of available parameters.
float generic_6dof_joint_get_param(RID joint, int axis, int param)
Parameters
generic_6dof_joint_set_flag(RID, int, int, bool)
Sets the value of a given generic 6DOF joint flag. See G6DOFJointAxisFlag for the list of available flags.
void generic_6dof_joint_set_flag(RID joint, int axis, int flag, bool enable)
Parameters
generic_6dof_joint_set_param(RID, int, int, float)
Sets the value of a given generic 6DOF joint parameter. See G6DOFJointAxisParam for the list of available parameters.
void generic_6dof_joint_set_param(RID joint, int axis, int param, float value)
Parameters
get_process_info(int)
Returns information about the current state of the 3D physics engine. See ProcessInfo for a list of available states.
int get_process_info(int process_info)
Parameters
process_info
int
heightmap_shape_create
RID heightmap_shape_create
hinge_joint_get_flag(RID, int)
Qualifiers: const
Gets a hinge_joint flag (see HingeJointFlag constants).
bool hinge_joint_get_flag(RID joint, int flag)
Parameters
hinge_joint_get_param(RID, int)
Qualifiers: const
Gets a hinge_joint parameter (see HingeJointParam).
float hinge_joint_get_param(RID joint, int param)
Parameters
hinge_joint_set_flag(RID, int, bool)
Sets a hinge_joint flag (see HingeJointFlag constants).
void hinge_joint_set_flag(RID joint, int flag, bool enabled)
Parameters
hinge_joint_set_param(RID, int, float)
Sets a hinge_joint parameter (see HingeJointParam constants).
void hinge_joint_set_param(RID joint, int param, float value)
Parameters
joint_clear(RID)
void joint_clear(RID joint)
Parameters
joint
RID
joint_create
RID joint_create
joint_disable_collisions_between_bodies(RID, bool)
Sets whether the bodies attached to the Joint3D will collide with each other.
void joint_disable_collisions_between_bodies(RID joint, bool disable)
Parameters
joint_get_solver_priority(RID)
Qualifiers: const
Gets the priority value of the Joint3D.
int joint_get_solver_priority(RID joint)
Parameters
joint
RID
joint_get_type(RID)
Qualifiers: const
Returns the type of the Joint3D.
int joint_get_type(RID joint)
Parameters
joint
RID
joint_is_disabled_collisions_between_bodies(RID)
Qualifiers: const
Returns whether the bodies attached to the Joint3D will collide with each other.
bool joint_is_disabled_collisions_between_bodies(RID joint)
Parameters
joint
RID
joint_make_cone_twist(RID, RID, Transform3D, RID, Transform3D)
void joint_make_cone_twist(RID joint, RID body_A, Transform3D local_ref_A, RID body_B, Transform3D local_ref_B)
Parameters
joint
RIDbody_A
RIDlocal_ref_A
Transform3Dbody_B
RIDlocal_ref_B
Transform3D
joint_make_generic_6dof(RID, RID, Transform3D, RID, Transform3D)
Make the joint a generic six degrees of freedom (6DOF) joint. Use PhysicsServer3D.generic_6dof_joint_set_flag and PhysicsServer3D.generic_6dof_joint_set_param to set the joint's flags and parameters respectively.
void joint_make_generic_6dof(RID joint, RID body_A, Transform3D local_ref_A, RID body_B, Transform3D local_ref_B)
Parameters
joint
RIDbody_A
RIDlocal_ref_A
Transform3Dbody_B
RIDlocal_ref_B
Transform3D
joint_make_hinge(RID, RID, Transform3D, RID, Transform3D)
void joint_make_hinge(RID joint, RID body_A, Transform3D hinge_A, RID body_B, Transform3D hinge_B)
Parameters
joint
RIDbody_A
RIDhinge_A
Transform3Dbody_B
RIDhinge_B
Transform3D
joint_make_pin(RID, RID, Vector3, RID, Vector3)
void joint_make_pin(RID joint, RID body_A, Vector3 local_A, RID body_B, Vector3 local_B)
Parameters
joint_make_slider(RID, RID, Transform3D, RID, Transform3D)
void joint_make_slider(RID joint, RID body_A, Transform3D local_ref_A, RID body_B, Transform3D local_ref_B)
Parameters
joint
RIDbody_A
RIDlocal_ref_A
Transform3Dbody_B
RIDlocal_ref_B
Transform3D
joint_set_solver_priority(RID, int)
Sets the priority value of the Joint3D.
void joint_set_solver_priority(RID joint, int priority)
Parameters
pin_joint_get_local_a(RID)
Qualifiers: const
Returns position of the joint in the local space of body a of the joint.
Vector3 pin_joint_get_local_a(RID joint)
Parameters
joint
RID
pin_joint_get_local_b(RID)
Qualifiers: const
Returns position of the joint in the local space of body b of the joint.
Vector3 pin_joint_get_local_b(RID joint)
Parameters
joint
RID
pin_joint_get_param(RID, int)
Qualifiers: const
Gets a pin_joint parameter (see PinJointParam constants).
float pin_joint_get_param(RID joint, int param)
Parameters
pin_joint_set_local_a(RID, Vector3)
Sets position of the joint in the local space of body a of the joint.
void pin_joint_set_local_a(RID joint, Vector3 local_A)
Parameters
pin_joint_set_local_b(RID, Vector3)
Sets position of the joint in the local space of body b of the joint.
void pin_joint_set_local_b(RID joint, Vector3 local_B)
Parameters
pin_joint_set_param(RID, int, float)
Sets a pin_joint parameter (see PinJointParam constants).
void pin_joint_set_param(RID joint, int param, float value)
Parameters
separation_ray_shape_create
RID separation_ray_shape_create
set_active(bool)
Activates or deactivates the 3D physics engine.
void set_active(bool active)
Parameters
active
bool
shape_get_data(RID)
Qualifiers: const
Returns the shape data.
Variant shape_get_data(RID shape)
Parameters
shape
RID
shape_get_margin(RID)
Qualifiers: const
Returns the collision margin for the shape.
Note: This is not used in Godot Physics, so will always return 0
.
float shape_get_margin(RID shape)
Parameters
shape
RID
shape_get_type(RID)
Qualifiers: const
Returns the type of shape (see ShapeType constants).
int shape_get_type(RID shape)
Parameters
shape
RID
shape_set_data(RID, Variant)
Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created PhysicsServer3D.shape_get_type.
void shape_set_data(RID shape, Variant data)
Parameters
shape_set_margin(RID, float)
Sets the collision margin for the shape.
Note: This is not used in Godot Physics.
void shape_set_margin(RID shape, float margin)
Parameters
slider_joint_get_param(RID, int)
Qualifiers: const
Gets a slider_joint parameter (see SliderJointParam constants).
float slider_joint_get_param(RID joint, int param)
Parameters
slider_joint_set_param(RID, int, float)
Gets a slider_joint parameter (see SliderJointParam constants).
void slider_joint_set_param(RID joint, int param, float value)
Parameters
soft_body_add_collision_exception(RID, RID)
Adds the given body to the list of bodies exempt from collisions.
void soft_body_add_collision_exception(RID body, RID body_b)
Parameters
soft_body_create
Creates a new soft body and returns its internal RID.
RID soft_body_create
soft_body_get_bounds(RID)
Qualifiers: const
Returns the bounds of the given soft body in global coordinates.
AABB soft_body_get_bounds(RID body)
Parameters
body
RID
soft_body_get_collision_layer(RID)
Qualifiers: const
Returns the physics layer or layers that the given soft body belongs to.
int soft_body_get_collision_layer(RID body)
Parameters
body
RID
soft_body_get_collision_mask(RID)
Qualifiers: const
Returns the physics layer or layers that the given soft body can collide with.
int soft_body_get_collision_mask(RID body)
Parameters
body
RID
soft_body_get_damping_coefficient(RID)
Qualifiers: const
Returns the damping coefficient of the given soft body.
float soft_body_get_damping_coefficient(RID body)
Parameters
body
RID
soft_body_get_drag_coefficient(RID)
Qualifiers: const
Returns the drag coefficient of the given soft body.
float soft_body_get_drag_coefficient(RID body)
Parameters
body
RID
soft_body_get_linear_stiffness(RID)
Qualifiers: const
Returns the linear stiffness of the given soft body.
float soft_body_get_linear_stiffness(RID body)
Parameters
body
RID
soft_body_get_point_global_position(RID, int)
Qualifiers: const
Returns the current position of the given soft body point in global coordinates.
Vector3 soft_body_get_point_global_position(RID body, int point_index)
Parameters
soft_body_get_pressure_coefficient(RID)
Qualifiers: const
Returns the pressure coefficient of the given soft body.
float soft_body_get_pressure_coefficient(RID body)
Parameters
body
RID
soft_body_get_simulation_precision(RID)
Qualifiers: const
Returns the simulation precision of the given soft body.
int soft_body_get_simulation_precision(RID body)
Parameters
body
RID
soft_body_get_space(RID)
Qualifiers: const
Returns the RID of the space assigned to the given soft body.
RID soft_body_get_space(RID body)
Parameters
body
RID
soft_body_get_state(RID, int)
Qualifiers: const
Returns the given soft body state (see BodyState constants).
Note: Godot's default physics implementation does not support PhysicsServer3D.BODY_STATE_LINEAR_VELOCITY, PhysicsServer3D.BODY_STATE_ANGULAR_VELOCITY, PhysicsServer3D.BODY_STATE_SLEEPING, or PhysicsServer3D.BODY_STATE_CAN_SLEEP.
Variant soft_body_get_state(RID body, int state)
Parameters
soft_body_get_total_mass(RID)
Qualifiers: const
Returns the total mass assigned to the given soft body.
float soft_body_get_total_mass(RID body)
Parameters
body
RID
soft_body_is_point_pinned(RID, int)
Qualifiers: const
Returns whether the given soft body point is pinned.
bool soft_body_is_point_pinned(RID body, int point_index)
Parameters
soft_body_move_point(RID, int, Vector3)
Moves the given soft body point to a position in global coordinates.
void soft_body_move_point(RID body, int point_index, Vector3 global_position)
Parameters
soft_body_pin_point(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 PhysicsServer3D.soft_body_move_point.
void soft_body_pin_point(RID body, int point_index, bool pin)
Parameters
soft_body_remove_all_pinned_points(RID)
Unpins all points of the given soft body.
void soft_body_remove_all_pinned_points(RID body)
Parameters
body
RID
soft_body_remove_collision_exception(RID, RID)
Removes the given body from the list of bodies exempt from collisions.
void soft_body_remove_collision_exception(RID body, RID body_b)
Parameters
soft_body_set_collision_layer(RID, int)
Sets the physics layer or layers the given soft body belongs to.
void soft_body_set_collision_layer(RID body, int layer)
Parameters
soft_body_set_collision_mask(RID, int)
Sets the physics layer or layers the given soft body can collide with.
void soft_body_set_collision_mask(RID body, int mask)
Parameters
soft_body_set_damping_coefficient(RID, float)
Sets the damping coefficient of the given soft body. Higher values will slow down the body more noticeably when forces are applied.
void soft_body_set_damping_coefficient(RID body, float damping_coefficient)
Parameters
soft_body_set_drag_coefficient(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.
void soft_body_set_drag_coefficient(RID body, float drag_coefficient)
Parameters
soft_body_set_linear_stiffness(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).
void soft_body_set_linear_stiffness(RID body, float stiffness)
Parameters
soft_body_set_mesh(RID, RID)
Sets the mesh of the given soft body.
void soft_body_set_mesh(RID body, RID mesh)
Parameters
soft_body_set_pressure_coefficient(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.
void soft_body_set_pressure_coefficient(RID body, float pressure_coefficient)
Parameters
soft_body_set_ray_pickable(RID, bool)
Sets whether the given soft body will be pickable when using object picking.
void soft_body_set_ray_pickable(RID body, bool enable)
Parameters
soft_body_set_simulation_precision(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.
void soft_body_set_simulation_precision(RID body, int simulation_precision)
Parameters
soft_body_set_space(RID, RID)
Assigns a space to the given soft body (see space_create).
void soft_body_set_space(RID body, RID space)
Parameters
soft_body_set_state(RID, int, Variant)
Sets the given body state for the given body (see BodyState constants).
Note: Godot's default physics implementation does not support PhysicsServer3D.BODY_STATE_LINEAR_VELOCITY, PhysicsServer3D.BODY_STATE_ANGULAR_VELOCITY, PhysicsServer3D.BODY_STATE_SLEEPING, or PhysicsServer3D.BODY_STATE_CAN_SLEEP.
void soft_body_set_state(RID body, int state, Variant variant)
Parameters
soft_body_set_total_mass(RID, float)
Sets the total mass for the given soft body.
void soft_body_set_total_mass(RID body, float total_mass)
Parameters
soft_body_set_transform(RID, Transform3D)
Sets the global transform of the given soft body.
void soft_body_set_transform(RID body, Transform3D transform)
Parameters
body
RIDtransform
Transform3D
soft_body_update_rendering_server(RID, PhysicsServer3DRenderingServerHandler)
Requests that the physics server updates the rendering server with the latest positions of the given soft body's points through the rendering_server_handler
interface.
void soft_body_update_rendering_server(RID body, PhysicsServer3DRenderingServerHandler rendering_server_handler)
Parameters
body
RIDrendering_server_handler
PhysicsServer3DRenderingServerHandler
space_create
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 PhysicsServer3D.area_set_space, or to a body with PhysicsServer3D.body_set_space.
RID space_create
space_get_direct_state(RID)
Returns the state of a space, a PhysicsDirectSpaceState3D. This object can be used to make collision/intersection queries.
PhysicsDirectSpaceState3D space_get_direct_state(RID space)
Parameters
space
RID
space_get_param(RID, int)
Qualifiers: const
Returns the value of a space parameter.
float space_get_param(RID space, int param)
Parameters
space_is_active(RID)
Qualifiers: const
Returns whether the space is active.
bool space_is_active(RID space)
Parameters
space
RID
space_set_active(RID, bool)
Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
void space_set_active(RID space, bool active)
Parameters
space_set_param(RID, int, float)
Sets the value for a space parameter. A list of available parameters is on the SpaceParameter constants.
void space_set_param(RID space, int param, float value)
Parameters
sphere_shape_create
RID sphere_shape_create
world_boundary_shape_create
RID world_boundary_shape_create