CollisionObject3D
Abstract base class for 3D physics objects.
CollisionObject3D.swift:21class CollisionObject3D
Abstract base class for 3D physics objects. CollisionObject3D
can hold any number of Shape3D
s for collision. Each shape must be assigned to a shape owner. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_*
methods.
This object emits the following signals:
Superclasses
class Node3D
Most basic 3D game object, parent of all 3D-related nodes.
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.
Types
enum DisableMode
class Signal1
Signal support.
Type members
Instance members
var collisionLayer: UInt32
The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also
collisionMask
.var collisionMask: UInt32
The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also
collisionLayer
.var collisionPriority: Double
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
var disableMode: CollisionObject3D.DisableMode
Defines the behavior in physics when
processMode
is set todisabled
. SeeDisableMode
for more details about the different modes.var inputCaptureOnDrag: Bool
If
true
, theCollisionObject3D
will continue to receive input events as the mouse is dragged across its shapes.var inputEvent: Signal1
Emitted when the object receives an unhandled
InputEvent
.position
is the location in world space of the mouse pointer on the surface of the shape with indexshapeIdx
andnormal
is the normal vector of the surface at that point.var inputRayPickable: Bool
If
true
, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least onecollisionLayer
bit to be set.var mouseEntered: SimpleSignal
Emitted when the mouse pointer enters any of this object’s shapes. Requires
inputRayPickable
to betrue
and at least onecollisionLayer
bit to be set.var mouseExited: SimpleSignal
Emitted when the mouse pointer exits all this object’s shapes. Requires
inputRayPickable
to betrue
and at least onecollisionLayer
bit to be set.func createShapeOwner(Object?
) -> UInt32 Creates a new shape owner for the given object. Returns
owner_id
of the new owner for future reference.func getCollisionLayerValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
collisionLayer
is enabled, given alayerNumber
between 1 and 32.func getCollisionMaskValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
collisionMask
is enabled, given alayerNumber
between 1 and 32.func getRid(
) -> RID Returns the object’s
RID
.func getShapeOwners(
) -> PackedInt32Array Returns an
GArray
ofowner_id
identifiers. You can use these ids in other methods that takeowner_id
as an argument.func isShapeOwnerDisabled(ownerId: UInt32
) -> Bool If
true
, the shape owner and its shapes are disabled.func removeShapeOwner(ownerId: UInt32
) Removes the given shape owner.
func setCollisionLayerValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thecollisionLayer
, given alayerNumber
between 1 and 32.func setCollisionMaskValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thecollisionMask
, given alayerNumber
between 1 and 32.func shapeFindOwner(shapeIndex: Int32
) -> UInt32 Returns the
owner_id
of the given shape.func shapeOwnerAddShape(ownerId: UInt32, shape: Shape3D?
) Adds a
Shape3D
to the shape owner.func shapeOwnerClearShapes(ownerId: UInt32
) Removes all shapes from the shape owner.
func shapeOwnerGetOwner(ownerId: UInt32
) -> Object? Returns the parent object of the given shape owner.
func shapeOwnerGetShape(ownerId: UInt32, shapeId: Int32
) -> Shape3D? Returns the
Shape3D
with the given ID from the given shape owner.func shapeOwnerGetShapeCount(ownerId: UInt32
) -> Int32 Returns the number of shapes the given shape owner contains.
func shapeOwnerGetShapeIndex(ownerId: UInt32, shapeId: Int32
) -> Int32 Returns the child index of the
Shape3D
with the given ID from the given shape owner.func shapeOwnerGetTransform(ownerId: UInt32
) -> Transform3D Returns the shape owner’s
Transform3D
.func shapeOwnerRemoveShape(ownerId: UInt32, shapeId: Int32
) Removes a shape from the given shape owner.
func shapeOwnerSetDisabled(ownerId: UInt32, disabled: Bool
) If
true
, disables the given shape owner.func shapeOwnerSetTransform(ownerId: UInt32, transform: Transform3D
) Sets the
Transform3D
of the given shape owner.
Show implementation details (3)
Hide implementation details
func _inputEvent(camera: Camera3D?, event: InputEvent?, position: Vector3, normal: Vector3, shapeIdx: Int32
) Receives unhandled
InputEvent
s.position
is the location in world space of the mouse pointer on the surface of the shape with indexshapeIdx
andnormal
is the normal vector of the surface at that point. Connect to the [signal input_event] signal to easily pick up these events.func _mouseEnter(
) Called when the mouse pointer enters any of this object’s shapes. Requires
inputRayPickable
to betrue
and at least onecollisionLayer
bit to be set. Note that moving between different shapes within a singleCollisionObject3D
won’t cause this function to be called.func _mouseExit(
) Called when the mouse pointer exits all this object’s shapes. Requires
inputRayPickable
to betrue
and at least onecollisionLayer
bit to be set. Note that moving between different shapes within a singleCollisionObject3D
won’t cause this function to be called.
Subclasses
class Area3D
A region of 3D space that detects other
CollisionObject3D
s entering or exiting it.class PhysicsBody3D
Abstract base class for 3D game objects affected by physics.