Enumerationmigueldeicaza.swiftgodot 0.45.0SwiftGodot
PinJointFlag
PhysicsServer2D.swift:361enum PinJointFlag
Cases
case angularLimitEnabled
If
true
, the pin has a maximum and a minimum rotation.case motorEnabled
If
true
, a motor turns the pin.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (135) members.
Types
enum AreaBodyStatus
enum AreaParameter
enum AreaSpaceOverrideMode
enum BodyDampMode
enum BodyMode
enum BodyParameter
enum BodyState
enum CCDMode
enum DampedSpringParam
enum JointParam
enum JointType
enum PinJointParam
enum ProcessInfo
enum ShapeType
enum SpaceParameter
Type members
static func areaAddShape(area: RID, shape: RID, transform: Transform2D, disabled: Bool
) Adds a shape to the area, with the given local transform. The shape (together with its
transform
anddisabled
properties) is added to an array of shapes, and the shapes of an area are usually referenced by their index in this array.static func areaAttachCanvasInstanceId(area: RID, id: UInt
) Attaches the
ObjectID
of a canvas to the area. UsegetInstanceId
to get theObjectID
of aCanvasLayer
.static func areaAttachObjectInstanceId(area: RID, id: UInt
) Attaches the
ObjectID
of anObject
to the area. UsegetInstanceId
to get theObjectID
of aCollisionObject2D
.static func areaClearShapes(area: RID
) Removes all shapes from the area. This does not delete the shapes themselves, so they can continue to be used elsewhere or added back later.
static func areaCreate(
) -> RID Creates a 2D area object in the physics server, and returns the
RID
that identifies it. UseareaAddShape(area:shape:transform:disabled:)
to add shapes to it, useareaSetTransform(area:transform:)
to set its transform, and useareaSetSpace(area:space:)
to add the area to a space.static func areaGetCanvasInstanceId(area: RID
) -> UInt Returns the
ObjectID
of the canvas attached to the area. Use@GlobalScope.instance_from_id
to retrieve aCanvasLayer
from a nonzeroObjectID
.static func areaGetCollisionLayer(area: RID
) -> UInt32 Returns the physics layer or layers the area belongs to, as a bitmask.
static func areaGetCollisionMask(area: RID
) -> UInt32 Returns the physics layer or layers the area can contact with, as a bitmask.
static func areaGetObjectInstanceId(area: RID
) -> UInt Returns the
ObjectID
attached to the area. Use@GlobalScope.instance_from_id
to retrieve anObject
from a nonzeroObjectID
.static func areaGetParam(area: RID, param: PhysicsServer2D.AreaParameter
) -> Variant Returns the value of the given area parameter. See
AreaParameter
for the list of available parameters.static func areaGetShape(area: RID, shapeIdx: Int32
) -> RID Returns the
RID
of the shape with the given index in the area’s array of shapes.static func areaGetShapeCount(area: RID
) -> Int32 Returns the number of shapes added to the area.
static func areaGetShapeTransform(area: RID, shapeIdx: Int32
) -> Transform2D Returns the local transform matrix of the shape with the given index in the area’s array of shapes.
static func areaGetSpace(area: RID
) -> RID Returns the
RID
of the space assigned to the area. Returns an emptyRID
if no space is assigned.static func areaGetTransform(area: RID
) -> Transform2D Returns the transform matrix of the area.
static func areaRemoveShape(area: RID, shapeIdx: Int32
) Removes the shape with the given index from the area’s array of shapes. The shape itself is not deleted, so it can continue to be used elsewhere or added back later. As a result of this operation, the area’s shapes which used to have indices higher than
shapeIdx
will have their index decreased by one.static func areaSetAreaMonitorCallback(area: RID, callback: 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:
static func areaSetCollisionLayer(area: RID, layer: UInt32
) Assigns the area to one or many physics layers, via a bitmask.
static func areaSetCollisionMask(area: RID, mask: UInt32
) Sets which physics layers the area will monitor, via a bitmask.
static func areaSetMonitorCallback(area: RID, callback: 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:
static func areaSetMonitorable(area: RID, monitorable: Bool
) Sets whether the area is monitorable or not. If
monitorable
istrue
, the area monitoring callback of other areas will be called when this area enters or exits them.static func areaSetParam(area: RID, param: PhysicsServer2D.AreaParameter, value: Variant
) Sets the value of the given area parameter. See
AreaParameter
for the list of available parameters.static func areaSetShape(area: RID, shapeIdx: Int32, shape: RID
) Replaces the area’s shape at the given index by another shape, while not affecting the
transform
anddisabled
properties at the same index.static func areaSetShapeDisabled(area: RID, shapeIdx: Int32, disabled: Bool
) Sets the disabled property of the area’s shape with the given index. If
disabled
istrue
, then the shape will not detect any other shapes entering or exiting it.static func areaSetShapeTransform(area: RID, shapeIdx: Int32, transform: Transform2D
) Sets the local transform matrix of the area’s shape with the given index.
static func areaSetSpace(area: RID, space: RID
) Adds the area to the given space, after removing the area from the previously assigned space (if any).
static func areaSetTransform(area: RID, transform: Transform2D
) Sets the transform matrix of the area.
static func bodyAddCollisionException(body: RID, exceptedBody: RID
) Adds
exceptedBody
to the body’s list of collision exceptions, so that collisions with it are ignored.static func bodyAddConstantCentralForce(body: RID, force: Vector2
) Adds a constant directional force to the body. The force does not affect rotation. The force remains applied over time until cleared with
PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))
.static func bodyAddConstantForce(body: RID, force: Vector2, position: Vector2
) Adds a constant positioned force to the body. The force can affect rotation if
position
is different from the body’s center of mass. The force remains applied over time until cleared withPhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))
.static func bodyAddConstantTorque(body: RID, torque: Double
) Adds a constant rotational force to the body. The force does not affect position. The force remains applied over time until cleared with
PhysicsServer2D.body_set_constant_torque(body, 0)
.static func bodyAddShape(body: RID, shape: RID, transform: Transform2D, disabled: Bool
) Adds a shape to the area, with the given local transform. The shape (together with its
transform
anddisabled
properties) is added to an array of shapes, and the shapes of a body are usually referenced by their index in this array.static func bodyApplyCentralForce(body: RID, force: Vector2
) Applies a directional force to the body, at the body’s center of mass. The force does not affect rotation. A force is time dependent and meant to be applied every physics update.
static func bodyApplyCentralImpulse(body: RID, impulse: Vector2
) Applies a directional impulse to the body, at the body’s center of mass. The impulse does not affect rotation.
static func bodyApplyForce(body: RID, force: Vector2, position: Vector2
) Applies a positioned force to the body. The force can affect rotation if
position
is different from the body’s center of mass. A force is time dependent and meant to be applied every physics update.static func bodyApplyImpulse(body: RID, impulse: Vector2, position: Vector2
) Applies a positioned impulse to the body. The impulse can affect rotation if
position
is different from the body’s center of mass.static func bodyApplyTorque(body: RID, torque: Double
) Applies a rotational force to the body. The force does not affect position. A force is time dependent and meant to be applied every physics update.
static func bodyApplyTorqueImpulse(body: RID, impulse: Double
) Applies a rotational impulse to the body. The impulse does not affect position.
static func bodyAttachCanvasInstanceId(body: RID, id: UInt
) Attaches the
ObjectID
of a canvas to the body. UsegetInstanceId
to get theObjectID
of aCanvasLayer
.static func bodyAttachObjectInstanceId(body: RID, id: UInt
) Attaches the
ObjectID
of anObject
to the body. UsegetInstanceId
to get theObjectID
of aCollisionObject2D
.static func bodyClearShapes(body: RID
) Removes all shapes from the body. This does not delete the shapes themselves, so they can continue to be used elsewhere or added back later.
static func bodyCreate(
) -> RID Creates a 2D body object in the physics server, and returns the
RID
that identifies it. UsebodyAddShape(body:shape:transform:disabled:)
to add shapes to it, usebodySetState(body:state:value:)
to set its transform, and usebodySetSpace(body:space:)
to add the body to a space.static func bodyGetCanvasInstanceId(body: RID
) -> UInt Returns the
ObjectID
of the canvas attached to the body. Use@GlobalScope.instance_from_id
to retrieve aCanvasLayer
from a nonzeroObjectID
.static func bodyGetCollisionLayer(body: RID
) -> UInt32 Returns the physics layer or layers the body belongs to, as a bitmask.
static func bodyGetCollisionMask(body: RID
) -> UInt32 Returns the physics layer or layers the body can collide with, as a bitmask.
static func bodyGetCollisionPriority(body: RID
) -> Double Returns the body’s collision priority. This is used in the depenetration phase of
bodyTestMotion(body:parameters:result:)
. The higher the priority is, the lower the penetration into the body will be.static func bodyGetConstantForce(body: RID
) -> Vector2 Returns the body’s total constant positional force applied during each physics update.
static func bodyGetConstantTorque(body: RID
) -> Double Returns the body’s total constant rotational force applied during each physics update.
static func bodyGetContinuousCollisionDetectionMode(body: RID
) -> PhysicsServer2D.CCDMode Returns the body’s continuous collision detection mode (see
CCDMode
).static func bodyGetDirectState(body: RID
) -> PhysicsDirectBodyState2D? Returns the
PhysicsDirectBodyState2D
of the body. Returnsnull
if the body is destroyed or not assigned to a space.static func bodyGetMaxContactsReported(body: RID
) -> Int32 Returns the maximum number of contacts that the body can report. See
bodySetMaxContactsReported(body:amount:)
.static func bodyGetMode(body: RID
) -> PhysicsServer2D.BodyMode Returns the body’s mode (see
BodyMode
).static func bodyGetObjectInstanceId(body: RID
) -> UInt Returns the
ObjectID
attached to the body. Use@GlobalScope.instance_from_id
to retrieve anObject
from a nonzeroObjectID
.static func bodyGetParam(body: RID, param: PhysicsServer2D.BodyParameter
) -> Variant Returns the value of the given body parameter. See
BodyParameter
for the list of available parameters.static func bodyGetShape(body: RID, shapeIdx: Int32
) -> RID Returns the
RID
of the shape with the given index in the body’s array of shapes.static func bodyGetShapeCount(body: RID
) -> Int32 Returns the number of shapes added to the body.
static func bodyGetShapeTransform(body: RID, shapeIdx: Int32
) -> Transform2D Returns the local transform matrix of the shape with the given index in the area’s array of shapes.
static func bodyGetSpace(body: RID
) -> RID Returns the
RID
of the space assigned to the body. Returns an emptyRID
if no space is assigned.static func bodyGetState(body: RID, state: PhysicsServer2D.BodyState
) -> Variant Returns the value of the given state of the body. See
BodyState
for the list of available states.static func bodyIsOmittingForceIntegration(body: RID
) -> Bool Returns
true
if the body uses a callback function to calculate its own physics (seebodySetForceIntegrationCallback(body:callable:userdata:)
).static func bodyRemoveCollisionException(body: RID, exceptedBody: RID
) Removes
exceptedBody
from the body’s list of collision exceptions, so that collisions with it are no longer ignored.static func bodyRemoveShape(body: RID, shapeIdx: Int32
) Removes the shape with the given index from the body’s array of shapes. The shape itself is not deleted, so it can continue to be used elsewhere or added back later. As a result of this operation, the body’s shapes which used to have indices higher than
shapeIdx
will have their index decreased by one.static func bodyResetMassProperties(body: RID
) Restores the default inertia and center of mass of the body based on its shapes. This undoes any custom values previously set using
bodySetParam(body:param:value:)
.static func bodySetAxisVelocity(body: RID, axisVelocity: Vector2
) Modifies the body’s linear velocity so that its projection to the axis
axis_velocity.normalized()
is exactlyaxis_velocity.length()
. This is useful for jumping behavior.static func bodySetCollisionLayer(body: RID, layer: UInt32
) Sets the physics layer or layers the body belongs to, via a bitmask.
static func bodySetCollisionMask(body: RID, mask: UInt32
) Sets the physics layer or layers the body can collide with, via a bitmask.
static func bodySetCollisionPriority(body: RID, priority: Double
) Sets the body’s collision priority. This is used in the depenetration phase of
bodyTestMotion(body:parameters:result:)
. The higher the priority is, the lower the penetration into the body will be.static func bodySetConstantForce(body: RID, force: Vector2
) Sets the body’s total constant positional force applied during each physics update.
static func bodySetConstantTorque(body: RID, torque: Double
) Sets the body’s total constant rotational force applied during each physics update.
static func bodySetContinuousCollisionDetectionMode(body: RID, mode: PhysicsServer2D.CCDMode
) Sets the continuous collision detection mode using one of the
CCDMode
constants.static func bodySetForceIntegrationCallback(body: RID, callable: Callable, userdata: Variant
) Sets the function used to calculate physics for the body, if that body allows it (see
bodySetOmitForceIntegration(body:enable:)
).static func bodySetMaxContactsReported(body: RID, amount: Int32
) Sets the maximum number of contacts that the body can report. If
amount
is greater than zero, then the body will keep track of at most this many contacts with other bodies.static func bodySetMode(body: RID, mode: PhysicsServer2D.BodyMode
) Sets the body’s mode. See
BodyMode
for the list of available modes.static func bodySetOmitForceIntegration(body: RID, enable: Bool
) Sets whether the body uses a callback function to calculate its own physics (see
bodySetForceIntegrationCallback(body:callable:userdata:)
).static func bodySetParam(body: RID, param: PhysicsServer2D.BodyParameter, value: Variant
) Sets the value of the given body parameter. See
BodyParameter
for the list of available parameters.static func bodySetShape(body: RID, shapeIdx: Int32, shape: RID
) Replaces the body’s shape at the given index by another shape, while not affecting the
transform
,disabled
, and one-way collision properties at the same index.static func bodySetShapeAsOneWayCollision(body: RID, shapeIdx: Int32, enable: Bool, margin: Double
) Sets the one-way collision properties of the body’s shape with the given index. If
enable
istrue
, the one-way collision direction given by the shape’s local upward axisbody_get_shape_transform(body, shape_idx).y
will be used to ignore collisions with the shape in the opposite direction, and to ensure depenetration of kinematic bodies happens in this direction.static func bodySetShapeDisabled(body: RID, shapeIdx: Int32, disabled: Bool
) Sets the disabled property of the body’s shape with the given index. If
disabled
istrue
, then the shape will be ignored in all collision detection.static func bodySetShapeTransform(body: RID, shapeIdx: Int32, transform: Transform2D
) Sets the local transform matrix of the body’s shape with the given index.
static func bodySetSpace(body: RID, space: RID
) Adds the body to the given space, after removing the body from the previously assigned space (if any). If the body’s mode is set to .rigid, then adding the body to a space will have the following additional effects:
static func bodySetState(body: RID, state: PhysicsServer2D.BodyState, value: Variant
) Sets the value of a body’s state. See
BodyState
for the list of available states.static func bodyTestMotion(body: RID, parameters: PhysicsTestMotionParameters2D?, result: PhysicsTestMotionResult2D?
) -> Bool Returns
true
if a collision would result from moving the body along a motion vector from a given point in space. SeePhysicsTestMotionParameters2D
for the available motion parameters. Optionally aPhysicsTestMotionResult2D
object can be passed, which will be used to store the information about the resulting collision.static func capsuleShapeCreate(
) -> RID Creates a 2D capsule shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the capsule’s height and radius.static func circleShapeCreate(
) -> RID Creates a 2D circle shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the circle’s radius.static func concavePolygonShapeCreate(
) -> RID Creates a 2D concave polygon shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the concave polygon’s segments.static func convexPolygonShapeCreate(
) -> RID Creates a 2D convex polygon shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the convex polygon’s points.static func dampedSpringJointGetParam(joint: RID, param: PhysicsServer2D.DampedSpringParam
) -> Double Returns the value of the given damped spring joint parameter. See
DampedSpringParam
for the list of available parameters.static func dampedSpringJointSetParam(joint: RID, param: PhysicsServer2D.DampedSpringParam, value: Double
) Sets the value of the given damped spring joint parameter. See
DampedSpringParam
for the list of available parameters.static func freeRid(RID
) Destroys any of the objects created by PhysicsServer2D. If the
RID
passed is not one of the objects that can be created by PhysicsServer2D, an error will be printed to the console.static func getProcessInfo(PhysicsServer2D.ProcessInfo
) -> Int32 Returns information about the current state of the 2D physics engine. See
ProcessInfo
for the list of available states.static func jointClear(joint: RID
) Destroys the joint with the given
RID
, creates a new uninitialized joint, and makes theRID
refer to this new joint.static func jointCreate(
) -> RID Creates a 2D joint in the physics server, and returns the
RID
that identifies it. To set the joint type, usejointMakeDampedSpring(joint:anchorA:anchorB:bodyA:bodyB:)
,jointMakeGroove(joint:groove1A:groove2A:anchorB:bodyA:bodyB:)
orjointMakePin(joint:anchor:bodyA:bodyB:)
. UsejointSetParam(joint:param:value:)
to set generic joint parameters.static func jointDisableCollisionsBetweenBodies(joint: RID, disable: Bool
) Sets whether the bodies attached to the
Joint2D
will collide with each other.static func jointGetParam(joint: RID, param: PhysicsServer2D.JointParam
) -> Double Returns the value of the given joint parameter. See
JointParam
for the list of available parameters.static func jointGetType(joint: RID
) -> PhysicsServer2D.JointType Returns the joint’s type (see
JointType
).static func jointIsDisabledCollisionsBetweenBodies(joint: RID
) -> Bool Returns whether the bodies attached to the
Joint2D
will collide with each other.static func jointMakeDampedSpring(joint: RID, anchorA: Vector2, anchorB: Vector2, bodyA: RID, bodyB: RID
) Makes the joint a damped spring joint, attached at the point
anchorA
(given in global coordinates) on the bodybodyA
and at the pointanchorB
(given in global coordinates) on the bodybodyB
. To set the parameters which are specific to the damped spring, seedampedSpringJointSetParam(joint:param:value:)
.static func jointMakeGroove(joint: RID, groove1A: Vector2, groove2A: Vector2, anchorB: Vector2, bodyA: RID, bodyB: RID
) Makes the joint a groove joint.
static func jointMakePin(joint: RID, anchor: Vector2, bodyA: RID, bodyB: RID
) Makes the joint a pin joint. If
bodyB
is an emptyRID
, thenbodyA
is pinned to the pointanchor
(given in global coordinates); otherwise,bodyA
is pinned tobodyB
at the pointanchor
(given in global coordinates). To set the parameters which are specific to the pin joint, seepinJointSetParam(joint:param:value:)
.static func jointSetParam(joint: RID, param: PhysicsServer2D.JointParam, value: Double
) Sets the value of the given joint parameter. See
JointParam
for the list of available parameters.static func pinJointGetFlag(joint: RID, flag: PhysicsServer2D.PinJointFlag
) -> Bool Gets a pin joint flag (see
PinJointFlag
constants).static func pinJointGetParam(joint: RID, param: PhysicsServer2D.PinJointParam
) -> Double Returns the value of a pin joint parameter. See
PinJointParam
for a list of available parameters.static func pinJointSetFlag(joint: RID, flag: PhysicsServer2D.PinJointFlag, enabled: Bool
) Sets a pin joint flag (see
PinJointFlag
constants).static func pinJointSetParam(joint: RID, param: PhysicsServer2D.PinJointParam, value: Double
) Sets a pin joint parameter. See
PinJointParam
for a list of available parameters.static func rectangleShapeCreate(
) -> RID Creates a 2D rectangle shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the rectangle’s half-extents.static func segmentShapeCreate(
) -> RID Creates a 2D segment shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the segment’s start and end points.static func separationRayShapeCreate(
) -> RID Creates a 2D separation ray shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the shape’slength
andslide_on_slope
properties.static func setActive(Bool
) Activates or deactivates the 2D physics server. If
active
isfalse
, then the physics server will not do anything in its physics step.static func shapeGetData(shape: RID
) -> Variant Returns the shape data that defines the configuration of the shape, such as the half-extents of a rectangle or the segments of a concave shape. See
shapeSetData(shape:data:)
for the precise format of this data in each case.static func shapeGetType(shape: RID
) -> PhysicsServer2D.ShapeType Returns the shape’s type (see
ShapeType
).static func shapeSetData(shape: RID, data: Variant
) Sets the shape data that defines the configuration of the shape. The
data
to be passed depends on the shape’s type (seeshapeGetType(shape:)
):static func spaceCreate(
) -> RID Creates a 2D space in the physics server, and returns the
RID
that identifies it. A space contains bodies and areas, and controls the stepping of the physics simulation of the objects in it.static func spaceGetDirectState(space: RID
) -> PhysicsDirectSpaceState2D? Returns the state of a space, a
PhysicsDirectSpaceState2D
. This object can be used for collision/intersection queries.static func spaceGetParam(space: RID, param: PhysicsServer2D.SpaceParameter
) -> Double Returns the value of the given space parameter. See
SpaceParameter
for the list of available parameters.static func spaceIsActive(space: RID
) -> Bool Returns
true
if the space is active.static func spaceSetActive(space: RID, active: Bool
) Activates or deactivates the space. If
active
isfalse
, then the physics server will not do anything with this space in its physics step.static func spaceSetParam(space: RID, param: PhysicsServer2D.SpaceParameter, value: Double
) Sets the value of the given space parameter. See
SpaceParameter
for the list of available parameters.static func worldBoundaryShapeCreate(
) -> RID Creates a 2D world boundary shape in the physics server, and returns the
RID
that identifies it. UseshapeSetData(shape:data:)
to set the shape’s normal direction and distance properties.class var godotClassName: StringName
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
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 RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.