Struct gdnative_bindings_lily::area_2d::Area2D [−][src]
pub struct Area2D { /* fields omitted */ }
Expand description
core class Area2D
inherits CollisionObject2D
(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.
Area2D
is a reference-only type. Persistent references can
only exist in the unsafe Ref<Area2D>
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
Area2D 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
Constants
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
.
The rate at which objects stop spinning in this area. Represents the angular velocity lost per second. Values range from 0
(no damping) to 1
(full damping).
The name of the area’s audio bus.
The area’s physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also [member collision_mask]. 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 layer mask. Describes whether other areas will collide with this one on the given layer.
The physics layers this area scans to determine collision detection. 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 collision mask. Describes whether this area will collide with others on the given layer.
The area’s gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
The area’s gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction.
The rate at which objects stop moving in this area. Represents the linear velocity lost per second. Values range from 0
(no damping) to 1
(full damping).
Returns a list of intersecting Area2Ds. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
Returns a list of intersecting PhysicsBody2Ds. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
Override mode for gravity and damping calculations within this area. See [enum SpaceOverride] for possible values.
If true
, gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override].
If true
, other monitoring areas can detect this area.
If true
, the area detects bodies or areas entering and exiting it.
If true
, the area’s audio bus overrides the default audio bus.
If true
, the given area overlaps the Area2D.
Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
If true
, the given physics body overlaps the Area2D.
Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
The body
argument can either be a PhysicsBody2D or a TileMap instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).
The rate at which objects stop spinning in this area. Represents the angular velocity lost per second. Values range from 0
(no damping) to 1
(full damping).
The name of the area’s audio bus.
If true
, the area’s audio bus overrides the default audio bus.
The area’s physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also [member collision_mask]. 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.
Set/clear individual bits on the layer mask. This makes getting an area in/out of only one layer easier.
The physics layers this area scans to determine collision detection. 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.
Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier.
The area’s gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
If true
, gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override].
The area’s gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction.
The rate at which objects stop moving in this area. Represents the linear velocity lost per second. Values range from 0
(no damping) to 1
(full damping).
If true
, other monitoring areas can detect this area.
If true
, the area detects bodies or areas entering and exiting it.
The area’s priority. Higher priority areas are processed first.
Override mode for gravity and damping calculations within this area. See [enum SpaceOverride] for possible values.
Methods from Deref<Target = CollisionObject2D>
Creates a new shape owner for the given object. Returns owner_id
of the new owner for future reference.
Returns the one_way_collision_margin
of the shape owner identified by given owner_id
.
Returns an [Array] of owner_id
identifiers. You can use these ids in other methods that take owner_id
as an argument.
If true
, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one collision_layer
bit to be set.
If true
, the shape owner and its shapes are disabled.
Returns true
if collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.
Removes the given shape owner.
If true
, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one collision_layer
bit to be set.
Returns the owner_id
of the given shape.
Adds a Shape2D to the shape owner.
Removes all shapes from the shape owner.
Returns the parent object of the given shape owner.
Returns the Shape2D with the given id from the given shape owner.
Returns the number of shapes the given shape owner contains.
Returns the child index of the Shape2D with the given id from the given shape owner.
Returns the shape owner’s Transform2D.
Removes a shape from the given shape owner.
If true
, disables the given shape owner.
If enable
is true
, collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.
Sets the one_way_collision_margin
of the shape owner identified by given owner_id
to margin
pixels.
Sets the Transform2D of the given shape owner.
Trait Implementations
type Target = CollisionObject2D
type Target = CollisionObject2D
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 Area2D
impl UnwindSafe for Area2D