Index · Object → PhysicsDirectBodyState3D

PhysicsDirectBodyState3D

Provides direct access to a physics body in the PhysicsServer3D.

Inherited by (1): PhysicsDirectBodyState3DExtension
Class Description

Provides direct access to a physics body in the PhysicsServer3D, allowing safe changes to physics properties. This object is passed via the direct state callback of RigidBody3D, and is intended for changing the direct state of that body. See RigidBody3D._integrate_forces().

Properties

var angular_velocity: Vector3

The body's rotational velocity in radians per second.

var center_of_mass: Vector3

The body's center of mass position relative to the body's center in the global coordinate system.

var center_of_mass_local: Vector3

The body's center of mass position in the body's local coordinate system.

var collision_layer: int

The body's collision layer.

var collision_mask: int

The body's collision mask.

var inverse_inertia: Vector3

The inverse of the inertia of the body.

var inverse_inertia_tensor: Basis

The inverse of the inertia tensor of the body.

var inverse_mass: float

The inverse of the mass of the body.

var linear_velocity: Vector3

The body's linear velocity in units per second.

var principal_inertia_axes: Basis
var sleeping: bool

If true, this body is currently sleeping (not active).

var step: float

The timestep (delta) used for the simulation.

var total_angular_damp: float

The rate at which the body stops rotating, if there are not any other forces moving it.

var total_gravity: Vector3

The total gravity vector being currently applied to this body.

var total_linear_damp: float

The rate at which the body stops moving, if there are not any other forces moving it.

var transform: Transform3D

The body's transformation matrix.

Methods

func add_constant_central_force(force: Vector3 = Vector3(0, 0, 0)) -> void

Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).

This is equivalent to using add_constant_force() at the body's center of mass.

func add_constant_force(force: Vector3, position: Vector3 = Vector3(0, 0, 0)) -> void

Adds a constant positioned force to the body that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).

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

func add_constant_torque(torque: Vector3) -> void

Adds a constant rotational force without affecting position that keeps being applied over time until cleared with constant_torque = Vector3(0, 0, 0).

func apply_central_force(force: Vector3 = Vector3(0, 0, 0)) -> void

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

This is equivalent to using apply_force() at the body's center of mass.

func apply_central_impulse(impulse: Vector3 = Vector3(0, 0, 0)) -> void

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

func apply_force(force: Vector3, position: Vector3 = Vector3(0, 0, 0)) -> void

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.

func apply_impulse(impulse: Vector3, position: Vector3 = Vector3(0, 0, 0)) -> void

Applies a positioned impulse to the body.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).

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

func apply_torque(torque: Vector3) -> void

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

Note: inverse_inertia is required for this to work. To have inverse_inertia, an active CollisionShape3D must be a child of the node, or you can manually set inverse_inertia.

func apply_torque_impulse(impulse: Vector3) -> void

Applies a rotational impulse to the body without affecting the position.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).

Note: inverse_inertia is required for this to work. To have inverse_inertia, an active CollisionShape3D must be a child of the node, or you can manually set inverse_inertia.

func get_constant_force() -> Vector3

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

See add_constant_force() and add_constant_central_force().

func get_constant_torque() -> Vector3

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

See add_constant_torque().

func get_contact_collider(contact_idx: int) -> RID

Returns the collider's RID.

func get_contact_collider_id(contact_idx: int) -> int

Returns the collider's object id.

func get_contact_collider_object(contact_idx: int) -> Object

Returns the collider object.

func get_contact_collider_position(contact_idx: int) -> Vector3

Returns the position of the contact point on the collider in the global coordinate system.

func get_contact_collider_shape(contact_idx: int) -> int

Returns the collider's shape index.

func get_contact_collider_velocity_at_position(contact_idx: int) -> Vector3

Returns the linear velocity vector at the collider's contact point.

func get_contact_count() -> int

Returns the number of contacts this body has with other bodies.

Note: By default, this returns 0 unless bodies are configured to monitor contacts. See RigidBody3D.contact_monitor.

func get_contact_impulse(contact_idx: int) -> Vector3

Impulse created by the contact.

func get_contact_local_normal(contact_idx: int) -> Vector3

Returns the local normal at the contact point.

func get_contact_local_position(contact_idx: int) -> Vector3

Returns the position of the contact point on the body in the global coordinate system.

func get_contact_local_shape(contact_idx: int) -> int

Returns the local shape index of the collision.

func get_contact_local_velocity_at_position(contact_idx: int) -> Vector3

Returns the linear velocity vector at the body's contact point.

func get_space_state() -> PhysicsDirectSpaceState3D

Returns the current state of the space, useful for queries.

func get_velocity_at_local_position(local_position: Vector3) -> Vector3

Returns the body's velocity at the given relative position.

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

func integrate_forces() -> void

Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.

func set_constant_force(force: Vector3) -> void

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

See add_constant_force() and add_constant_central_force().

func set_constant_torque(torque: Vector3) -> void

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

See add_constant_torque().

Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)