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

bool can_collide_with_character_bodies ( ) const

Return if this body can collide with character bodies.

bool can_collide_with_kinematic_bodies ( ) const

Return if this body can collide with kinematic bodies.

bool can_collide_with_rigid_bodies ( ) const

Return if this body can collide with rigid bodies.

bool can_collide_with_static_bodies ( ) const

Return if this body can collide with static bodies.

bool can_teleport_to ( Vector3 position )

Returns whether the KinematicBody can be teleported to the destination given as an argument, checking all collision shapes of the body against potential colliders at the destination.

Variant get_collider ( ) const

Return the body that collided with this one.

int get_collider_shape ( ) const

Return the shape index from the body that collided with this one. If there is no collision, this method will return 0, so collisions must be checked first with is_colliding.

Vector3 get_collider_velocity ( ) const

Return the velocity of the body that collided with this one.

float get_collision_margin ( ) const

Return the collision margin for this object.

Vector3 get_collision_normal ( ) const

Return the normal of the surface the body collided with. This is useful to implement sliding along a surface.

Vector3 get_collision_pos ( ) const

Return the point in space where the body is touching another. If there is no collision, this method will return (0,0,0), so collisions must be checked first with is_colliding.

bool is_colliding ( ) const

Return whether the body is colliding with another.

Vector3 move ( Vector3 rel_vec )

Move the body in the given direction, stopping if there is an obstacle. The returned vector is how much movement was remaining before being stopped.

Vector3 move_to ( Vector3 position )

Move the body to the given position. This is not a teleport, and the body will stop if there is an obstacle. The returned vector is how much movement was remaining before being stopped.

void set_collide_with_character_bodies ( bool enable )

Set if this body should collide with character bodies.

void set_collide_with_kinematic_bodies ( bool enable )

Set if this body should collide with kinematic bodies.

void set_collide_with_rigid_bodies ( bool enable )

Set if this body should collide with rigid bodies.

void set_collide_with_static_bodies ( bool enable )

Set if this body should collide with static bodies.

void set_collision_margin ( float pixels )

Set the collision margin for this object. A collision margin is an amount that all shapes will grow when computing collisions, to account for numerical imprecision.

© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/2.1/classes/class_kinematicbody.html