PhysicsDirectBodyState3D
Provides direct access to a physics body in the PhysicsServer3D
.
class PhysicsDirectBodyState3D
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 _integrateForces(state:)
.
Superclasses
class Object
Base class for all other classes in the engine.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var angularVelocity: Vector3
The body’s rotational velocity in radians per second.
var centerOfMass: Vector3
The body’s center of mass position relative to the body’s center in the global coordinate system.
var centerOfMassLocal: Vector3
The body’s center of mass position in the body’s local coordinate system.
var inverseInertia: Vector3
The inverse of the inertia of the body.
var inverseInertiaTensor: Basis
The inverse of the inertia tensor of the body.
var inverseMass: Double
The inverse of the mass of the body.
var linearVelocity: Vector3
The body’s linear velocity in units per second.
var principalInertiaAxes: Basis
var sleeping: Bool
If
true
, this body is currently sleeping (not active).var step: Double
The timestep (delta) used for the simulation.
var totalAngularDamp: Double
The rate at which the body stops rotating, if there are not any other forces moving it.
var totalGravity: Vector3
The total gravity vector being currently applied to this body.
var totalLinearDamp: Double
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.
func addConstantCentralForce(Vector3
) Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with
constant_force = Vector3(0, 0, 0)
.func addConstantForce(Vector3, position: Vector3
) Adds a constant positioned force to the body that keeps being applied over time until cleared with
constant_force = Vector3(0, 0, 0)
.func addConstantTorque(Vector3
) Adds a constant rotational force without affecting position that keeps being applied over time until cleared with
constant_torque = Vector3(0, 0, 0)
.func applyCentralForce(Vector3
) Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
func applyCentralImpulse(Vector3
) Applies a directional impulse without affecting rotation.
func applyForce(Vector3, position: Vector3
) Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
func applyImpulse(Vector3, position: Vector3
) Applies a positioned impulse to the body.
func applyTorque(Vector3
) Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
func applyTorqueImpulse(Vector3
) Applies a rotational impulse to the body without affecting the position.
func getConstantForce(
) -> Vector3 Returns the body’s total constant positional forces applied during each physics update.
func getConstantTorque(
) -> Vector3 Returns the body’s total constant rotational forces applied during each physics update.
func getContactCollider(contactIdx: Int32
) -> RID Returns the collider’s
RID
.func getContactColliderId(contactIdx: Int32
) -> UInt Returns the collider’s object id.
func getContactColliderObject(contactIdx: Int32
) -> Object? Returns the collider object.
func getContactColliderPosition(contactIdx: Int32
) -> Vector3 Returns the position of the contact point on the collider in the global coordinate system.
func getContactColliderShape(contactIdx: Int32
) -> Int32 Returns the collider’s shape index.
func getContactColliderVelocityAtPosition(contactIdx: Int32
) -> Vector3 Returns the linear velocity vector at the collider’s contact point.
func getContactCount(
) -> Int32 Returns the number of contacts this body has with other bodies.
func getContactImpulse(contactIdx: Int32
) -> Vector3 Impulse created by the contact.
func getContactLocalNormal(contactIdx: Int32
) -> Vector3 Returns the local normal at the contact point.
func getContactLocalPosition(contactIdx: Int32
) -> Vector3 Returns the position of the contact point on the body in the global coordinate system.
func getContactLocalShape(contactIdx: Int32
) -> Int32 Returns the local shape index of the collision.
func getContactLocalVelocityAtPosition(contactIdx: Int32
) -> Vector3 Returns the linear velocity vector at the body’s contact point.
func getSpaceState(
) -> PhysicsDirectSpaceState3D? Returns the current state of the space, useful for queries.
func getVelocityAtLocalPosition(Vector3
) -> Vector3 Returns the body’s velocity at the given relative position, including both translation and rotation.
func integrateForces(
) Updates the body’s linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
func setConstantForce(Vector3
) Sets the body’s total constant positional forces applied during each physics update.
func setConstantTorque(Vector3
) Sets the body’s total constant rotational forces applied during each physics update.
Subclasses
class PhysicsDirectBodyState3DExtension
Provides virtual methods that can be overridden to create custom
PhysicsDirectBodyState3D
implementations.