KinematicCollision2D
Holds collision data from the movement of a PhysicsBody2D
.
class KinematicCollision2D
Holds collision data from the movement of a PhysicsBody2D
, usually from moveAndCollide(motion:testOnly:safeMargin:recoveryAsCollision:)
. When a PhysicsBody2D
is moved, it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision2D
object is returned.
The collision data includes the colliding object, the remaining motion, and the collision position. This data can be used to determine a custom response to the collision.
Superclasses
class RefCounted
Base class for reference-counted objects.
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.
Type members
Instance members
func getAngle(upDirection: Vector2
) -> Double Returns the collision angle according to
upDirection
, which isVector2.UP
by default. This value is always positive.func getCollider(
) -> Object? Returns the colliding body’s attached
Object
.func getColliderId(
) -> UInt Returns the unique instance ID of the colliding body’s attached
Object
. SeegetInstanceId
.func getColliderRid(
) -> RID Returns the colliding body’s
RID
used by thePhysicsServer2D
.func getColliderShape(
) -> Object? Returns the colliding body’s shape.
func getColliderShapeIndex(
) -> Int32 Returns the colliding body’s shape index. See
CollisionObject2D
.func getColliderVelocity(
) -> Vector2 Returns the colliding body’s velocity.
func getDepth(
) -> Double Returns the colliding body’s length of overlap along the collision normal.
func getLocalShape(
) -> Object? Returns the moving object’s colliding shape.
func getNormal(
) -> Vector2 Returns the colliding body’s shape’s normal at the point of collision.
func getPosition(
) -> Vector2 Returns the point of collision in global coordinates.
func getRemainder(
) -> Vector2 Returns the moving object’s remaining movement vector.
func getTravel(
) -> Vector2 Returns the moving object’s travel before collision.