Struct gdnative_bindings_lily::KinematicBody [−][src]
pub struct KinematicBody { /* fields omitted */ }
Expand description
core class KinematicBody
inherits PhysicsBody
(unsafe).
Official documentation
See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.
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
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
.
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 true
.
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 true
.
If the body is at least this close to another body, this body will consider them to be colliding.
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).
Returns the number of times the body collided and changed direction during the last call to [method move_and_slide].
Returns true
if the body is on the ceiling. Only updates when calling [method move_and_slide].
Returns true
if the body is on the floor. Only updates when calling [method move_and_slide].
Returns true
if the body is on a wall. Only updates when calling [method move_and_slide].
pub fn move_and_collide(
&self,
rel_vec: Vector3,
infinite_inertia: bool,
exclude_raycast_shapes: bool,
test_only: bool
) -> Option<Ref<KinematicCollision, Shared>>
pub fn move_and_collide(
&self,
rel_vec: Vector3,
infinite_inertia: bool,
exclude_raycast_shapes: bool,
test_only: bool
) -> Option<Ref<KinematicCollision, Shared>>
Moves the body along the vector rel_vec
. The body will stop if it collides. Returns a KinematicCollision, which contains information about the collision.
If test_only
is true
, 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
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 delta
value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
linear_velocity
is the velocity vector (typically meters per second). Unlike in [method move_and_collide], you should [i]not[/i] multiply it by delta
— the physics engine handles applying the velocity.
up_direction
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 Vector3(0, 0, 0)
, everything is considered a wall.
If stop_on_slope
is true
, body will not slide on slopes when you include gravity in linear_velocity
and the body is standing still.
If the body collides, it will change direction a maximum of max_slides
times before it stops.
floor_max_angle
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 infinite_inertia
is true
, body will be able to push RigidBody nodes, but it won’t also detect any collisions with them. If false
, it will interact with RigidBody nodes like with StaticBody.
Returns the linear_velocity
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
Moves the body while keeping it attached to slopes. Similar to [method move_and_slide].
As long as the snap
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 snap
to (0, 0, 0)
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
Lock the body’s Z axis movement.
If the body is at least this close to another body, this body will consider them to be colliding.
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 rel_vec
. Returns true
if a collision would occur.
Default Arguments
infinite_inertia
-true
Methods from Deref<Target = PhysicsBody>
Adds a body to the list of bodies that this body can’t collide with.
Returns an array of nodes that were added as collision exceptions for this body.
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.
Returns an individual bit on the [member collision_layer].
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.
Returns an individual bit on the [member collision_mask].
Removes a body from the list of bodies that this body can’t collide with.
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.
Sets individual bits on the [member collision_layer] bitmask. Use this if you only need to change one layer’s value.
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.
Sets individual bits on the [member collision_mask] bitmask. Use this if you only need to change one layer’s value.
Trait Implementations
type Target = PhysicsBody
type Target = PhysicsBody
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
type RefKind = ManuallyManaged
type RefKind = ManuallyManaged
Creates an explicitly null reference of Self
as a method argument. This makes type
inference easier for the compiler compared to Option
. Read more
Creates a new instance of Self
using a zero-argument constructor, as a Unique
reference. Read more
Performs a dynamic reference downcast to target type. Read more
Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more
Creates a persistent reference to the same Godot object with shared thread access. Read more
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
Creates a persistent reference to the same Godot object with thread-local thread access. Read more
Creates a persistent reference to the same Godot object with unique access. Read more
Recovers a instance ID previously returned by Object::get_instance_id
if the object is
still alive. See also TRef::try_from_instance_id
. Read more
Auto Trait Implementations
impl RefUnwindSafe for KinematicBody
impl !Send for KinematicBody
impl !Sync for KinematicBody
impl Unpin for KinematicBody
impl UnwindSafe for KinematicBody