Class reference
KinematicCollision3D
Inherits RefCounted
Holds collision data from the movement of a PhysicsBody3D.
Description
Holds collision data from the movement of a PhysicsBody3D, usually from PhysicsBody3D.move_and_collide(). When a PhysicsBody3D is moved, it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision3D 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.
Methods
float get_angle(int collision_index = 0, Vector3 up_direction = Vector3(0, 1, 0)) const
float get_angle(int collision_index = 0, Vector3 up_direction = Vector3(0, 1, 0)) constReturns the collision angle according to up_direction, which is Vector3.UP by default. This value is always positive.
Object get_collider(int collision_index = 0) const
Object get_collider(int collision_index = 0) constReturns the colliding body's attached Object given a collision index (the deepest collision by default).
int get_collider_id(int collision_index = 0) const
int get_collider_id(int collision_index = 0) constReturns the unique instance ID of the colliding body's attached Object given a collision index (the deepest collision by default). See Object.get_instance_id().
RID get_collider_rid(int collision_index = 0) const
RID get_collider_rid(int collision_index = 0) constReturns the colliding body's RID used by the PhysicsServer3D given a collision index (the deepest collision by default).
Object get_collider_shape(int collision_index = 0) const
Object get_collider_shape(int collision_index = 0) constReturns the colliding body's shape given a collision index (the deepest collision by default).
int get_collider_shape_index(int collision_index = 0) const
int get_collider_shape_index(int collision_index = 0) constReturns the colliding body's shape index given a collision index (the deepest collision by default). See CollisionObject3D.
Vector3 get_collider_velocity(int collision_index = 0) const
Vector3 get_collider_velocity(int collision_index = 0) constReturns the colliding body's velocity given a collision index (the deepest collision by default).
int get_collision_count() const
int get_collision_count() constReturns the number of detected collisions.
float get_depth() const
float get_depth() constReturns the colliding body's length of overlap along the collision normal.
Object get_local_shape(int collision_index = 0) const
Object get_local_shape(int collision_index = 0) constReturns the moving object's colliding shape given a collision index (the deepest collision by default).
Vector3 get_normal(int collision_index = 0) const
Vector3 get_normal(int collision_index = 0) constReturns the colliding body's shape's normal at the point of collision given a collision index (the deepest collision by default).
Vector3 get_position(int collision_index = 0) const
Vector3 get_position(int collision_index = 0) constReturns the point of collision in global coordinates given a collision index (the deepest collision by default).
Vector3 get_remainder() const
Vector3 get_remainder() constReturns the moving object's remaining movement vector.
Vector3 get_travel() const
Vector3 get_travel() constReturns the moving object's travel before collision.