[][src]Struct gdnative::prelude::KinematicBody

pub struct KinematicBody { /* fields omitted */ }

core class KinematicBody inherits PhysicsBody (unsafe).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

Memory management

Non reference counted objects such as the ones of this type are usually owned by the engine.

KinematicBody is a reference-only type. Persistent references can only exist in the unsafe Ref<KinematicBody> form.

In the cases where Rust code owns an object of this type, for example if the object was just created on the Rust side and not passed to the engine yet, ownership should be either given to the engine or the object must be manually destroyed using Ref::free, or Ref::queue_free if it is a Node.

Class hierarchy

KinematicBody inherits methods from:

Safety

All types in the Godot API have "interior mutability" in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

impl KinematicBody[src]

pub fn new() -> Ref<KinematicBody, Unique>[src]

Creates a new instance of this object.

Because this type is not reference counted, the lifetime of the returned object is not automatically managed.

Immediately after creation, the object is owned by the caller, and can be passed to the engine (in which case the engine will be responsible for destroying the object) or destroyed manually using Ref::free, or preferably Ref::queue_free if it is a Node.

pub fn axis_lock(&self, axis: i64) -> bool[src]

Lock the body's Z axis movement.

pub fn get_floor_normal(&self) -> Vector3D<f32, UnknownUnit>[src]

Returns the surface normal of the floor at the last collision point. Only valid after calling [method move_and_slide] or [method move_and_slide_with_snap] and when [method is_on_floor] returns [code]true[/code].

pub fn get_floor_velocity(&self) -> Vector3D<f32, UnknownUnit>[src]

Returns the linear velocity of the floor at the last collision point. Only valid after calling [method move_and_slide] or [method move_and_slide_with_snap] and when [method is_on_floor] returns [code]true[/code].

pub fn safe_margin(&self) -> f64[src]

If the body is at least this close to another body, this body will consider them to be colliding.

pub fn get_slide_collision(
    &self,
    slide_idx: i64
) -> Option<Ref<KinematicCollision, Shared>>
[src]

Returns a [KinematicCollision], which contains information about a collision that occurred during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1).

pub fn get_slide_count(&self) -> i64[src]

Returns the number of times the body collided and changed direction during the last call to [method move_and_slide].

pub fn is_on_ceiling(&self) -> bool[src]

Returns [code]true[/code] if the body is on the ceiling. Only updates when calling [method move_and_slide].

pub fn is_on_floor(&self) -> bool[src]

Returns [code]true[/code] if the body is on the floor. Only updates when calling [method move_and_slide].

pub fn is_on_wall(&self) -> bool[src]

Returns [code]true[/code] if the body is on a wall. Only updates when calling [method move_and_slide].

pub fn move_and_collide(
    &self,
    rel_vec: Vector3D<f32, UnknownUnit>,
    infinite_inertia: bool,
    exclude_raycast_shapes: bool,
    test_only: bool
) -> Option<Ref<KinematicCollision, Shared>>
[src]

Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision], which contains information about the collision.
				If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given.

Default Arguments

  • infinite_inertia - true
  • exclude_raycast_shapes - true
  • test_only - false

pub fn move_and_slide(
    &self,
    linear_velocity: Vector3D<f32, UnknownUnit>,
    up_direction: Vector3D<f32, UnknownUnit>,
    stop_on_slope: bool,
    max_slides: i64,
    floor_max_angle: f64,
    infinite_inertia: bool
) -> Vector3D<f32, UnknownUnit>
[src]

Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [KinematicBody] or [RigidBody], it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes.
				This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
				[code]linear_velocity[/code] is the velocity vector (typically meters per second). Unlike in [method move_and_collide], you should [i]not[/i] multiply it by [code]delta[/code] — the physics engine handles applying the velocity.
				[code]up_direction[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector3(0, 0, 0)[/code], everything is considered a wall.
				If [code]stop_on_slope[/code] is [code]true[/code], body will not slide on slopes when you include gravity in [code]linear_velocity[/code] and the body is standing still.
				If the body collides, it will change direction a maximum of [code]max_slides[/code] times before it stops.
				[code]floor_max_angle[/code] is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees.
				If [code]infinite_inertia[/code] is [code]true[/code], body will be able to push [RigidBody] nodes, but it won't also detect any collisions with them. If [code]false[/code], it will interact with [RigidBody] nodes like with [StaticBody].
				Returns the [code]linear_velocity[/code] vector, rotated and/or scaled if a slide collision occurred. To get detailed information about collisions that occurred, use [method get_slide_collision].

Default Arguments

  • up_direction - Vector3( 0, 0, 0 )
  • stop_on_slope - false
  • max_slides - 4
  • floor_max_angle - 0.785398
  • infinite_inertia - true

pub fn move_and_slide_with_snap(
    &self,
    linear_velocity: Vector3D<f32, UnknownUnit>,
    snap: Vector3D<f32, UnknownUnit>,
    up_direction: Vector3D<f32, UnknownUnit>,
    stop_on_slope: bool,
    max_slides: i64,
    floor_max_angle: f64,
    infinite_inertia: bool
) -> Vector3D<f32, UnknownUnit>
[src]

Moves the body while keeping it attached to slopes. Similar to [method move_and_slide].
				As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code](0, 0, 0)[/code] or by using [method move_and_slide] instead.

Default Arguments

  • up_direction - Vector3( 0, 0, 0 )
  • stop_on_slope - false
  • max_slides - 4
  • floor_max_angle - 0.785398
  • infinite_inertia - true

pub fn set_axis_lock(&self, axis: i64, lock: bool)[src]

Lock the body's Z axis movement.

pub fn set_safe_margin(&self, pixels: f64)[src]

If the body is at least this close to another body, this body will consider them to be colliding.

pub fn test_move(
    &self,
    from: Transform,
    rel_vec: Vector3D<f32, UnknownUnit>,
    infinite_inertia: bool
) -> bool
[src]

Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given [Transform], then tries to move the body along the vector [code]rel_vec[/code]. Returns [code]true[/code] if a collision would occur.

Default Arguments

  • infinite_inertia - true

Methods from Deref<Target = PhysicsBody>

pub fn add_collision_exception_with(&self, body: impl AsArg<Node>)[src]

Adds a body to the list of bodies that this body can't collide with.

pub fn get_collision_exceptions(&self) -> VariantArray<Shared>[src]

Returns an array of nodes that were added as collision exceptions for this body.

pub fn collision_layer(&self) -> i64[src]

The physics layers this area is in.
			Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the [member collision_mask] property.
			A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.

pub fn get_collision_layer_bit(&self, bit: i64) -> bool[src]

Returns an individual bit on the [member collision_layer].

pub fn collision_mask(&self) -> i64[src]

The physics layers this area scans for collisions. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.

pub fn get_collision_mask_bit(&self, bit: i64) -> bool[src]

Returns an individual bit on the [member collision_mask].

pub fn remove_collision_exception_with(&self, body: impl AsArg<Node>)[src]

Removes a body from the list of bodies that this body can't collide with.

pub fn set_collision_layer(&self, layer: i64)[src]

The physics layers this area is in.
			Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the [member collision_mask] property.
			A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.

pub fn set_collision_layer_bit(&self, bit: i64, value: bool)[src]

Sets individual bits on the [member collision_layer] bitmask. Use this if you only need to change one layer's value.

pub fn set_collision_mask(&self, mask: i64)[src]

The physics layers this area scans for collisions. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.

pub fn set_collision_mask_bit(&self, bit: i64, value: bool)[src]

Sets individual bits on the [member collision_mask] bitmask. Use this if you only need to change one layer's value.

Trait Implementations

impl Debug for KinematicBody[src]

impl Deref for KinematicBody[src]

type Target = PhysicsBody

The resulting type after dereferencing.

impl DerefMut for KinematicBody[src]

impl GodotObject for KinematicBody[src]

type RefKind = ManuallyManaged

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for KinematicBody[src]

impl QueueFree for KinematicBody[src]

impl SubClass<CollisionObject> for KinematicBody[src]

impl SubClass<Node> for KinematicBody[src]

impl SubClass<Object> for KinematicBody[src]

impl SubClass<PhysicsBody> for KinematicBody[src]

impl SubClass<Spatial> for KinematicBody[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.