Skip to main content

PhysicsBody2D

Struct PhysicsBody2D 

Source
pub struct PhysicsBody2D {
Show 13 fields pub position: Vec2, pub shape: Shape2D, pub velocity: Vec2, pub kind: BodyKind, pub filter: CollisionFilter, pub is_trigger: bool, pub mass: f32, pub gravity: Option<Vec2>, pub restitution: f32, pub friction: f32, pub drag: f32, pub max_speed: Option<f32>, pub grounded: bool,
}
Expand description

World collider, including solids and nonblocking trigger volumes.

Fields§

§position: Vec2

World-space center.

§shape: Shape2D

Local collision geometry.

§velocity: Vec2

Intrinsic velocity, excluding moving-platform carry.

§kind: BodyKind

Static, kinematic or dynamic motion authority.

§filter: CollisionFilter

Layer membership and symmetric acceptance mask.

§is_trigger: bool

Nonblocking volume that generates typed trigger events.

§mass: f32

Positive mass; affects dynamic/dynamic push-apart and impulses.

§gravity: Option<Vec2>

Optional per-body acceleration, in world units per second squared.

§restitution: f32

Bounce coefficient in [0, 1]. Pair response uses the maximum.

§friction: f32

Contact friction in [0, 1]; scales the normal impulse budget.

§drag: f32

Nonnegative drag per second, applied as velocity / (1 + drag * dt).

§max_speed: Option<f32>

Optional nonnegative intrinsic speed cap, applied after forces. Collision impulses may exceed it until the next tick.

§grounded: bool

Contact with a solid below (Y down in 2D, Y up in 3D).

Implementations§

Source§

impl PhysicsBody2D

Source

pub fn new(position: Vec2, shape: Shape2D) -> Self

Stationary dynamic collider with mass one and no automatic gravity.

Source

pub fn bounds(&self) -> Aabb2

Current conservative world bounds.

Trait Implementations§

Source§

impl Clone for PhysicsBody2D

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PhysicsBody2D

Source§

impl Debug for PhysicsBody2D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PhysicsBody2D

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PhysicsBody2D

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Component for T
where T: Send + Sync + 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.