Signal4
Signal support.
RigidBody3D.swift:2274class Signal4
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (49) members.
Types
enum CenterOfMassMode
enum DampMode
enum FreezeMode
class Signal1
Signal support.
class Signal2
Signal support.
class Signal3
Signal support.
Type members
Instance members
var angularDamp: Double
Damps the body’s rotation. By default, the body will use the Default Angular Damp in Project > Project Settings > Physics > 3d or any value override set by an
Area3D
the body is in. Depending onangularDampMode
, you can setangularDamp
to be added to or to replace the body’s damping value.var angularDampMode: RigidBody3D.DampMode
Defines how
angularDamp
is applied. SeeDampMode
for possible values.var angularVelocity: Vector3
The RigidBody3D’s rotational velocity in radians per second.
var bodyEntered: Signal3
Emitted when a collision with another
PhysicsBody3D
orGridMap
occurs. RequirescontactMonitor
to be set totrue
andmaxContactsReported
to be set high enough to detect all the collisions.GridMap
s are detected if theMeshLibrary
has CollisionShape3D
s.var bodyExited: Signal4
Emitted when the collision with another
PhysicsBody3D
orGridMap
ends. RequirescontactMonitor
to be set totrue
andmaxContactsReported
to be set high enough to detect all the collisions.GridMap
s are detected if theMeshLibrary
has CollisionShape3D
s.var bodyShapeEntered: Signal1
Emitted when one of this RigidBody3D’s
Shape3D
s collides with anotherPhysicsBody3D
orGridMap
’sShape3D
s. RequirescontactMonitor
to be set totrue
andmaxContactsReported
to be set high enough to detect all the collisions.GridMap
s are detected if theMeshLibrary
has CollisionShape3D
s.var bodyShapeExited: Signal2
Emitted when the collision between one of this RigidBody3D’s
Shape3D
s and anotherPhysicsBody3D
orGridMap
’sShape3D
s ends. RequirescontactMonitor
to be set totrue
andmaxContactsReported
to be set high enough to detect all the collisions.GridMap
s are detected if theMeshLibrary
has CollisionShape3D
s.var canSleep: Bool
If
true
, the body can enter sleep mode when there is no movement. Seesleeping
.var centerOfMass: Vector3
The body’s custom center of mass, relative to the body’s origin position, when
centerOfMassMode
is set to .custom. This is the balanced point of the body, where applied forces only cause linear acceleration. Applying forces outside of the center of mass causes angular acceleration.var centerOfMassMode: RigidBody3D.CenterOfMassMode
Defines the way the body’s center of mass is set. See
CenterOfMassMode
for possible values.var constantForce: Vector3
The body’s total constant positional forces applied during each physics update.
var constantTorque: Vector3
The body’s total constant rotational forces applied during each physics update.
var contactMonitor: Bool
If
true
, the RigidBody3D will emit signals when it collides with another body.var continuousCd: Bool
If
true
, continuous collision detection is used.var customIntegrator: Bool
If
true
, internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the_integrateForces(state:)
function, if defined.var freeze: Bool
If
true
, the body is frozen. Gravity and forces are not applied anymore.var freezeMode: RigidBody3D.FreezeMode
The body’s freeze mode. Can be used to set the body’s behavior when
freeze
is enabled. SeeFreezeMode
for possible values.var gravityScale: Double
This is multiplied by the global 3D gravity setting found in Project > Project Settings > Physics > 3d to produce RigidBody3D’s gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
var inertia: Vector3
The body’s moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body on each axis. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value.
var linearDamp: Double
Damps the body’s movement. By default, the body will use the Default Linear Damp in Project > Project Settings > Physics > 3d or any value override set by an
Area3D
the body is in. Depending onlinearDampMode
, you can setlinearDamp
to be added to or to replace the body’s damping value.var linearDampMode: RigidBody3D.DampMode
Defines how
linearDamp
is applied. SeeDampMode
for possible values.var linearVelocity: Vector3
The body’s linear velocity in units per second. Can be used sporadically, but don’t set this every frame, because physics may run in another thread and runs at a different granularity. Use
_integrateForces(state:)
as your process loop for precise control of the body state.var lockRotation: Bool
If
true
, the body cannot rotate. Gravity and forces only apply linear movement.var mass: Double
The body’s mass.
var maxContactsReported: Int32
The maximum number of contacts that will be recorded. Requires a value greater than 0 and
contactMonitor
to be set totrue
to start to register contacts. UsegetContactCount
to retrieve the count orgetCollidingBodies
to retrieve bodies that have been collided with.var physicsMaterialOverride: PhysicsMaterial?
The physics material override for the body.
var sleeping: Bool
If
true
, the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using theapplyImpulse(_:position:)
orapplyForce(_:position:)
methods.var sleepingStateChanged: SimpleSignal
Emitted when the physics engine changes the body’s sleeping state.
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 getCollidingBodies(
) -> ObjectCollection<Node3D> Returns a list of the bodies colliding with this one. Requires
contactMonitor
to be set totrue
andmaxContactsReported
to be set high enough to detect all the collisions.func getContactCount(
) -> Int32 Returns the number of contacts this body has with other bodies. By default, this returns 0 unless bodies are configured to monitor contacts (see
contactMonitor
).func getInverseInertiaTensor(
) -> Basis Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the
RigidBody3D
.func setAxisVelocity(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.
Show implementation details (1)
Hide implementation details
func _integrateForces(state: PhysicsDirectBodyState3D?
) Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the
customIntegrator
property allows you to disable the default behavior and do fully custom force integration for a body.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ body: Node) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)