Struct KinematicCollision2D

Collision data for KinematicBody2D collisions.

struct KinematicCollision2D ;

Contains collision data for KinematicBody2D collisions. When a KinematicBody2D is moved using KinematicBody2D.moveAndCollide, it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision2D object is returned. This object contains information about the collision, including the colliding object, the remaining motion, and the collision position. This information can be used to calculate a collision response.

Properties

NameTypeDescription
collider[get] GodotObjectThe colliding body.
colliderId[get] longThe colliding body's unique instance ID. See GodotObject.getInstanceId.
colliderMetadata[get] VariantThe colliding body's metadata. See GodotObject.
colliderShape[get] GodotObjectThe colliding body's shape.
colliderShapeIndex[get] longThe colliding shape's index. See CollisionObject2D.
colliderVelocity[get] Vector2The colliding object's velocity.
localShape[get] GodotObjectThe moving object's colliding shape.
normal[get] Vector2The colliding body's shape's normal at the point of collision.
position[get] Vector2The point of collision, in global coordinates.
remainder[get] Vector2The moving object's remaining movement vector.
travel[get] Vector2The distance the moving object traveled before collision.

Methods

NameDescription
getCollider
getColliderId
getColliderMetadata
getColliderShape
getColliderShapeIndex
getColliderVelocity
getLocalShape
getNormal
getPosition
getRemainder
getTravel