KinematicCollision2D

Inherits: Reference < Object

Collision data for KinematicBody2D collisions.

Description

Contains collision data for KinematicBody2D collisions. When a KinematicBody2D is moved using KinematicBody2D.move_and_collide, 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

Object

collider

int

collider_id

0

Variant

collider_metadata

RID

collider_rid

Object

collider_shape

int

collider_shape_index

0

Vector2

collider_velocity

Vector2( 0, 0 )

Object

local_shape

Vector2

normal

Vector2( 0, 0 )

Vector2

position

Vector2( 0, 0 )

Vector2

remainder

Vector2( 0, 0 )

Vector2

travel

Vector2( 0, 0 )

Methods

float

get_angle ( Vector2 up_direction=Vector2( 0, -1 ) ) const


Property Descriptions

Object collider

The colliding body.


int collider_id = 0

  • int get_collider_id ( )

The colliding body's unique instance ID. See Object.get_instance_id.


Variant collider_metadata

  • Variant get_collider_metadata ( )

The colliding body's metadata. See Object.


RID collider_rid

  • RID get_collider_rid ( )

The colliding body's RID used by the Physics2DServer.


Object collider_shape

  • Object get_collider_shape ( )

The colliding body's shape.


int collider_shape_index = 0

  • int get_collider_shape_index ( )

The colliding shape's index. See CollisionObject2D.


Vector2 collider_velocity = Vector2( 0, 0 )

  • Vector2 get_collider_velocity ( )

The colliding object's velocity.


Object local_shape

The moving object's colliding shape.


Vector2 normal = Vector2( 0, 0 )

The colliding body's shape's normal at the point of collision.


Vector2 position = Vector2( 0, 0 )

The point of collision, in global coordinates.


Vector2 remainder = Vector2( 0, 0 )

The moving object's remaining movement vector.


Vector2 travel = Vector2( 0, 0 )

The distance the moving object traveled before collision.


Method Descriptions

float get_angle ( Vector2 up_direction=Vector2( 0, -1 ) ) const

The collision angle according to up_direction, which is Vector2.UP by default. This value is always positive.