KinematicCollision2D

Inherits: RefCounted < Object

Collision data for PhysicsBody2D.move_and_collide collisions.

Description

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

Methods

float

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

Object

get_collider ( ) const

int

get_collider_id ( ) const

RID

get_collider_rid ( ) const

Object

get_collider_shape ( ) const

int

get_collider_shape_index ( ) const

Vector2

get_collider_velocity ( ) const

Object

get_local_shape ( ) const

Vector2

get_normal ( ) const

Vector2

get_position ( ) const

Vector2

get_remainder ( ) const

Vector2

get_travel ( ) const

Method Descriptions

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

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


  • Object get_collider ( ) const

Returns the colliding body's attached Object.


  • int get_collider_id ( ) const

Returns the unique instance ID of the colliding body's attached Object. See Object.get_instance_id.


  • RID get_collider_rid ( ) const

Returns the colliding body's RID used by the PhysicsServer2D.


  • Object get_collider_shape ( ) const

Returns the colliding body's shape.


  • int get_collider_shape_index ( ) const

Returns the colliding body's shape index. See CollisionObject2D.


  • Vector2 get_collider_velocity ( ) const

Returns the colliding body's velocity.


  • Object get_local_shape ( ) const

Returns the moving object's colliding shape.


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


Returns the point of collision in global coordinates.


Returns the moving object's remaining movement vector.


Returns the moving object's travel before collision.