KinematicBody

Inherits: PhysicsBody < CollisionObject < Spatial < Node < Object

Category: Core

Brief Description

Kinematic body 3D node.

Member Functions

bool can_collide_with_character_bodies ( ) const
bool can_collide_with_kinematic_bodies ( ) const
bool can_collide_with_rigid_bodies ( ) const
bool can_collide_with_static_bodies ( ) const
bool can_teleport_to ( Vector3 position )
Variant get_collider ( ) const
int get_collider_shape ( ) const
Vector3 get_collider_velocity ( ) const
float get_collision_margin ( ) const
Vector3 get_collision_normal ( ) const
Vector3 get_collision_pos ( ) const
bool is_colliding ( ) const
Vector3 move ( Vector3 rel_vec )
Vector3 move_to ( Vector3 position )
void set_collide_with_character_bodies ( bool enable )
void set_collide_with_kinematic_bodies ( bool enable )
void set_collide_with_rigid_bodies ( bool enable )
void set_collide_with_static_bodies ( bool enable )
void set_collision_margin ( float pixels )

Description

Kinematic bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all (to other types of bodies, such a character or a rigid body, these are the same as a static body). They have however, two main uses:

Simulated Motion: When these bodies are moved manually, either from code or from an AnimationPlayer (with process mode set to fixed), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc).

Kinematic Characters: KinematicBody also has an api for moving objects (the move method) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don’t require advanced physics.

Member Function Description

  • Object get_collision_collider ( int collision ) const
  • int get_collision_collider_id ( int collision ) const
  • Variant get_collision_collider_metadata ( int collision ) const
  • Object get_collision_collider_shape ( int collision ) const
  • int get_collision_collider_shape_index ( int collision ) const
  • Vector3 get_collision_collider_velocity ( int collision ) const
  • int get_collision_count ( ) const
  • Vector3 get_collision_normal ( int collision ) const
  • Vector3 get_collision_position ( int collision ) const
  • Vector3 get_collision_remainder ( int collision ) const
  • Vector3 get_collision_travel ( int collision ) const
  • Vector3 get_floor_velocity ( ) const
  • float get_safe_margin ( ) const
  • bool is_on_ceiling ( ) const
  • bool is_on_floor ( ) const
  • bool is_on_wall ( ) const

Move the body in the given direction, stopping if there is an obstacle. If as a result of a movement there will be any collision then informations about this collision will be in returned dictionary. Dictionary will contains those keys:

  • “position” - collision position
  • “normal” - collision normal
  • “local_shape” - id of this kinematic body shape that took part in a collision
  • “travel” - traveled movement before being stopped
  • “remainder” - remaining movement before being stopped
  • “collider_id” - id of the collider, it can be used when dealing with PhysicsServer
  • “collider” - colliding body
  • “collider_shape_index” - index of the colliding shape, inside collider body “collider_metadata”

If the body did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. Please note that this method is less user friendly than move_and_slide. If you don’t want to program each edge case manually, then it’s recommended to use move_and_slide instead.

  • Vector3 move_and_slide ( Vector3 linear_velocity, Vector3 floor_normal=4, float slope_stop_min_velocity=0.05, int max_bounces=Vector3( 0, 0, 0 ), float floor_max_angle=null )
  • void set_safe_margin ( float pixels )