Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
getCollisionCount
The number of collisions detected at the point of impact. Use this to iterate over multiple collisions as provided by getCollider(index:)
, getColliderShape(index:)
, getCollisionPoint(index:)
, and getCollisionNormal(index:)
methods.
final func getCollisionCount() -> Int32
Other members in extension
Type members
Instance members
var collideWithAreas: Bool
If
true
, collisions withArea2D
s will be reported.var collideWithBodies: Bool
If
true
, collisions withPhysicsBody2D
s will be reported.var collisionMask: UInt32
The shape’s collision mask. Only objects in at least one collision layer enabled in the mask will be detected.
var enabled: Bool
If
true
, collisions will be reported.var excludeParent: Bool
If
true
, the parent node will be excluded from collision detection.var margin: Double
The collision margin for the shape. A larger margin helps detecting collisions more consistently, at the cost of precision.
var maxResults: Int32
The number of intersections can be limited with this parameter, to reduce the processing time.
var shape: Shape2D?
The
Shape2D
-derived shape to be used for collision queries.var targetPosition: Vector2
The shape’s destination point, relative to this node’s
position
.func addException(node: CollisionObject2D?
) Adds a collision exception so the shape does not report collisions with the specified
CollisionObject2D
node.func addExceptionRid(RID
) Adds a collision exception so the shape does not report collisions with the specified
RID
.func clearExceptions(
) Removes all collision exceptions for this shape.
func forceShapecastUpdate(
) Updates the collision information for the shape immediately, without waiting for the next
_physics_process
call. Use this method, for example, when the shape or its parent has changed state.func getClosestCollisionSafeFraction(
) -> Double The fraction from the
ShapeCast2D
’s origin to itstargetPosition
(between 0 and 1) of how far the shape can move without triggering a collision.func getClosestCollisionUnsafeFraction(
) -> Double The fraction from the
ShapeCast2D
’s origin to itstargetPosition
(between 0 and 1) of how far the shape must move to trigger a collision.func getCollider(index: Int32
) -> Object? Returns the collided
Object
of one of the multiple collisions atindex
, ornull
if no object is intersecting the shape (i.e.isColliding
returnsfalse
).func getColliderRid(index: Int32
) -> RID Returns the
RID
of the collided object of one of the multiple collisions atindex
.func getColliderShape(index: Int32
) -> Int32 Returns the shape ID of the colliding shape of one of the multiple collisions at
index
, or0
if no object is intersecting the shape (i.e.isColliding
returnsfalse
).func getCollisionMaskValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
collisionMask
is enabled, given alayerNumber
between 1 and 32.func getCollisionNormal(index: Int32
) -> Vector2 Returns the normal of one of the multiple collisions at
index
of the intersecting object.func getCollisionPoint(index: Int32
) -> Vector2 Returns the collision point of one of the multiple collisions at
index
where the shape intersects the colliding object.func isColliding(
) -> Bool Returns whether any object is intersecting with the shape’s vector (considering the vector length).
func removeException(node: CollisionObject2D?
) Removes a collision exception so the shape does report collisions with the specified
CollisionObject2D
node.func removeExceptionRid(RID
) Removes a collision exception so the shape does report collisions with the specified
RID
.func setCollisionMaskValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thecollisionMask
, given alayerNumber
between 1 and 32.