CCDMode
RigidBody2D.swift:85enum CCDModeenum CCDModeimport SwiftGodotFramework to write Godot Game Extensions using the Swift Programming Language.
class RigidBody2DA 2D physics body that is moved by a physics simulation.
case disabledContinuous collision detection disabled. This is the fastest way to detect body collisions, but can miss small, fast-moving objects.
case castRayContinuous collision detection enabled using raycasting. This is faster than shapecasting but less precise.
case castShapeContinuous collision detection enabled using shapecasting. This is the slowest CCD method and the most precise.
override class var godotClassName: StringName { get }final var angularDamp: Double { get set }Damps the body’s rotation. By default, the body will use the Default Angular Damp in Project > Project Settings > Physics > 2d or any value override set by an Area2D the body is in. Depending on angularDampMode, you can set angularDamp to be added to or to replace the body’s damping value.
final var angularDampMode: RigidBody2D.DampMode { get set }Defines how angularDamp is applied. See DampMode for possible values.
final var angularVelocity: Double { get set }The body’s rotational velocity in radians per second.
var bodyEntered: Signal3 { get }Emitted when a collision with another PhysicsBody2D or TileMap occurs. Requires contactMonitor to be set to true and maxContactsReported to be set high enough to detect all the collisions. TileMaps are detected if the TileSet has Collision Shape2Ds.
var bodyExited: Signal4 { get }Emitted when the collision with another PhysicsBody2D or TileMap ends. Requires contactMonitor to be set to true and maxContactsReported to be set high enough to detect all the collisions. TileMaps are detected if the TileSet has Collision Shape2Ds.
var bodyShapeEntered: Signal1 { get }Emitted when one of this RigidBody2D’s Shape2Ds collides with another PhysicsBody2D or TileMap’s Shape2Ds. Requires contactMonitor to be set to true and maxContactsReported to be set high enough to detect all the collisions. TileMaps are detected if the TileSet has Collision Shape2Ds.
var bodyShapeExited: Signal2 { get }Emitted when the collision between one of this RigidBody2D’s Shape2Ds and another PhysicsBody2D or TileMap’s Shape2Ds ends. Requires contactMonitor to be set to true and maxContactsReported to be set high enough to detect all the collisions. TileMaps are detected if the TileSet has Collision Shape2Ds.
final var canSleep: Bool { get set }If true, the body can enter sleep mode when there is no movement. See sleeping.
final var centerOfMass: Vector2 { get set }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.
final var centerOfMassMode: RigidBody2D.CenterOfMassMode { get set }Defines the way the body’s center of mass is set. See CenterOfMassMode for possible values.
final var constantForce: Vector2 { get set }The body’s total constant positional forces applied during each physics update.
final var constantTorque: Double { get set }The body’s total constant rotational forces applied during each physics update.
final var contactMonitor: Bool { get set }If true, the RigidBody2D will emit signals when it collides with another body.
final var continuousCd: RigidBody2D.CCDMode { get set }Continuous collision detection mode.
final var customIntegrator: Bool { get set }If true, the standard force integration (like gravity or damping) will be disabled for this body. Other than collision response, the body will only move as determined by the _integrateForces(state:) method, if that virtual method is overridden.
final var freeze: Bool { get set }If true, the body is frozen. Gravity and forces are not applied anymore.
final var freezeMode: RigidBody2D.FreezeMode { get set }The body’s freeze mode. Can be used to set the body’s behavior when freeze is enabled. See FreezeMode for possible values.
final var gravityScale: Double { get set }Multiplies the gravity applied to the body. The body’s gravity is calculated from the Default Gravity value in Project > Project Settings > Physics > 2d and/or any additional gravity vector applied by Area2Ds.
final var inertia: Double { get set }The body’s moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value.
final var linearDamp: Double { get set }Damps the body’s movement. By default, the body will use the Default Linear Damp in Project > Project Settings > Physics > 2d or any value override set by an Area2D the body is in. Depending on linearDampMode, you can set linearDamp to be added to or to replace the body’s damping value.
final var linearDampMode: RigidBody2D.DampMode { get set }Defines how linearDamp is applied. See DampMode for possible values.
final var linearVelocity: Vector2 { get set }The body’s linear velocity in pixels 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.
final var lockRotation: Bool { get set }If true, the body cannot rotate. Gravity and forces only apply linear movement.
final var mass: Double { get set }The body’s mass.
final var maxContactsReported: Int32 { get set }The maximum number of contacts that will be recorded. Requires a value greater than 0 and contactMonitor to be set to true to start to register contacts. Use getContactCount to retrieve the count or getCollidingBodies to retrieve bodies that have been collided with.
final var physicsMaterialOverride: PhysicsMaterial? { get set }The physics material override for the body.
final var sleeping: Bool { get set }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 the applyImpulse(_:position:) or applyForce(_:position:) methods.
var sleepingStateChanged: SimpleSignal { get }Emitted when the physics engine changes the body’s sleeping state.
func _integrateForces(state: PhysicsDirectBodyState2D?) Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it is called before the standard force integration, but the customIntegrator property allows you to disable the standard force integration and do fully custom force integration for a body.
final func addConstantCentralForce(_ force: Vector2) Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with constant_force = Vector2(0, 0).
final func addConstantForce(_ force: Vector2, position: Vector2 = Vector2 (x: 0, y: 0)) Adds a constant positioned force to the body that keeps being applied over time until cleared with constant_force = Vector2(0, 0).
final func addConstantTorque(_ torque: Double) Adds a constant rotational force without affecting position that keeps being applied over time until cleared with constant_torque = 0.
final func applyCentralForce(_ force: Vector2) Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
final func applyCentralImpulse(_ impulse: Vector2 = Vector2 (x: 0, y: 0)) Applies a directional impulse without affecting rotation.
final func applyForce(_ force: Vector2, position: Vector2 = Vector2 (x: 0, y: 0)) Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
final func applyImpulse(_ impulse: Vector2, position: Vector2 = Vector2 (x: 0, y: 0)) Applies a positioned impulse to the body.
final func applyTorque(_ torque: Double) Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
final func applyTorqueImpulse(torque: Double) Applies a rotational impulse to the body without affecting the position.
final func getCollidingBodies() -> ObjectCollection<Node2D> Returns a list of the bodies colliding with this one. Requires contactMonitor to be set to true and maxContactsReported to be set high enough to detect all the collisions.
final 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).
final func setAxisVelocity(_ axisVelocity: Vector2) Sets the body’s velocity on the given axis. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
enum CenterOfMassModeenum DampModeenum FreezeModeclass Signal1Signal support.
class Signal2Signal support.
class Signal3Signal support.
class Signal4Signal support.
protocol CaseIterableA type that provides a collection of all of its values.
protocol CustomDebugStringConvertibleA type with a customized textual representation suitable for debugging purposes.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
protocol RawRepresentable<RawValue>A type that can be converted to and from an associated raw value.
init?(rawValue: Int64) var debugDescription: String { get }A textual representation of this instance, suitable for debugging
var hashValue: Int { get }static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.
func hash(into hasher: inout Hasher)