Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

KinematicCollision3D

继承: RefCounted < Object

存放移动 PhysicsBody3D 所产生的碰撞数据。

描述

存放移动 PhysicsBody3D 所产生的碰撞数据,通常是由 PhysicsBody3D.move_and_collide 产生的。移动 PhysicsBody3D 时,它会在检测到与另一个实体发生碰撞时停止。检测到碰撞时就会返回 KinematicCollision3D 对象。

碰撞数据包括碰撞对象、剩余运动和碰撞位置。可以使用该数据进行碰撞的自定义响应。

方法

float

get_angle ( int collision_index=0, Vector3 up_direction=Vector3(0, 1, 0) ) const

Object

get_collider ( int collision_index=0 ) const

int

get_collider_id ( int collision_index=0 ) const

RID

get_collider_rid ( int collision_index=0 ) const

Object

get_collider_shape ( int collision_index=0 ) const

int

get_collider_shape_index ( int collision_index=0 ) const

Vector3

get_collider_velocity ( int collision_index=0 ) const

int

get_collision_count ( ) const

float

get_depth ( ) const

Object

get_local_shape ( int collision_index=0 ) const

Vector3

get_normal ( int collision_index=0 ) const

Vector3

get_position ( int collision_index=0 ) const

Vector3

get_remainder ( ) const

Vector3

get_travel ( ) const


方法说明

float get_angle ( int collision_index=0, Vector3 up_direction=Vector3(0, 1, 0) ) const

根据 up_direction 返回碰撞角度,默认为 Vector3.UP。该值始终为正。


Object get_collider ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回该碰撞实体所附加的 Object


int get_collider_id ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回该碰撞实体所附加的 Object 的唯一实例 ID。请参阅 Object.get_instance_id


RID get_collider_rid ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回被 PhysicsServer3D 使用的碰撞实体的 RID


Object get_collider_shape ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回该碰撞实体的形状。


int get_collider_shape_index ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回该碰撞实体的形状索引。请参阅 CollisionObject3D


Vector3 get_collider_velocity ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回该碰撞实体的速度。


int get_collision_count ( ) const

返回检测到的碰撞次数。


float get_depth ( ) const

返回该碰撞物体沿碰撞法线覆盖的长度。


Object get_local_shape ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回移动的对象的碰撞形状。


Vector3 get_normal ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回在碰撞点处该碰撞实体的形状的法线。


Vector3 get_position ( int collision_index=0 ) const

给定碰撞索引(默认情况下最深的碰撞),返回以全局坐标表示的碰撞点。


Vector3 get_remainder ( ) const

返回移动对象的剩余移动向量。


Vector3 get_travel ( ) const

返回移动对象的在碰撞前的运动。