pub struct RigidBodyComponent {
pub handle: Option<RigidBodyHandle>,
pub body_type: RigidBodyType,
pub translation: [f32; 3],
pub rotation: [f32; 4],
pub linvel: [f32; 3],
pub angvel: [f32; 3],
pub mass: f32,
pub linear_damping: f32,
pub angular_damping: f32,
pub gravity_scale: f32,
pub locked_axes: LockedAxes,
pub ccd_enabled: bool,
}Expand description
Rigid body component for physics simulation.
Defines a physics body that can be dynamic (affected by forces), kinematic
(animated but affecting others), or static (fixed in place). Attach alongside
a ColliderComponent to participate in collision detection and response.
Fields§
§handle: Option<RigidBodyHandle>Internal handle assigned by the physics engine (managed automatically).
body_type: RigidBodyTypeBody type: Dynamic, KinematicPositionBased, KinematicVelocityBased, or Fixed.
translation: [f32; 3]Initial position in world space.
rotation: [f32; 4]Initial orientation as quaternion [x, y, z, w].
linvel: [f32; 3]Linear velocity in world units per second.
angvel: [f32; 3]Angular velocity in radians per second.
mass: f32Mass in kilograms (only affects dynamic bodies).
linear_damping: f32Linear velocity decay rate. 0.0 leaves motion to drag-free space, higher values bleed off translation over time. Default: 0.0.
angular_damping: f32Angular velocity decay rate. 0.0 spins forever, higher values settle rotation over time. Default: 0.0.
gravity_scale: f32Per-body multiplier on world gravity. 1.0 is normal, 0.0 floats, negative rises, 2.0 falls twice as hard. Default: 1.0.
locked_axes: LockedAxesConstraints on which axes can translate or rotate.
ccd_enabled: boolEnable continuous collision detection. Costs CPU but prevents fast-moving bodies from tunneling through thin geometry. Default: false.
Implementations§
Source§impl RigidBodyComponent
impl RigidBodyComponent
Sourcepub fn new_dynamic() -> RigidBodyComponent
pub fn new_dynamic() -> RigidBodyComponent
Creates a dynamic rigid body affected by forces and gravity.
Sourcepub fn new_kinematic() -> RigidBodyComponent
pub fn new_kinematic() -> RigidBodyComponent
Creates a kinematic rigid body driven by setting its translation each frame.
Sourcepub fn new_kinematic_velocity() -> RigidBodyComponent
pub fn new_kinematic_velocity() -> RigidBodyComponent
Creates a kinematic rigid body driven by setting its linear velocity. Unlike
the position-based kind, it responds to set_linvel, which is what scripts
use to move it, and dynamic bodies cannot push it.
Sourcepub fn new_static() -> RigidBodyComponent
pub fn new_static() -> RigidBodyComponent
Creates a static (fixed) rigid body that never moves.
Sourcepub fn with_translation(self, x: f32, y: f32, z: f32) -> RigidBodyComponent
pub fn with_translation(self, x: f32, y: f32, z: f32) -> RigidBodyComponent
Sets the initial translation.
Sourcepub fn with_mass(self, mass: f32) -> RigidBodyComponent
pub fn with_mass(self, mass: f32) -> RigidBodyComponent
Sets the mass in kilograms.
Sourcepub fn with_linear_damping(self, damping: f32) -> RigidBodyComponent
pub fn with_linear_damping(self, damping: f32) -> RigidBodyComponent
Sets the linear damping (translation decay rate).
Sourcepub fn with_angular_damping(self, damping: f32) -> RigidBodyComponent
pub fn with_angular_damping(self, damping: f32) -> RigidBodyComponent
Sets the angular damping (rotation decay rate).
Sourcepub fn with_gravity_scale(self, scale: f32) -> RigidBodyComponent
pub fn with_gravity_scale(self, scale: f32) -> RigidBodyComponent
Sets the per-body gravity multiplier.
Sourcepub fn with_rotation(self, x: f32, y: f32, z: f32, w: f32) -> RigidBodyComponent
pub fn with_rotation(self, x: f32, y: f32, z: f32, w: f32) -> RigidBodyComponent
Sets the initial rotation as a quaternion.
Sourcepub fn with_ccd(self, enabled: bool) -> RigidBodyComponent
pub fn with_ccd(self, enabled: bool) -> RigidBodyComponent
Enables continuous collision detection for this body. Use for fast-moving bodies that would otherwise tunnel through thin geometry (bullets, fast props).
Trait Implementations§
Source§impl Clone for RigidBodyComponent
impl Clone for RigidBodyComponent
Source§fn clone(&self) -> RigidBodyComponent
fn clone(&self) -> RigidBodyComponent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RigidBodyComponent
impl Debug for RigidBodyComponent
Source§impl Default for RigidBodyComponent
impl Default for RigidBodyComponent
Source§fn default() -> RigidBodyComponent
fn default() -> RigidBodyComponent
Source§impl<'de> Deserialize<'de> for RigidBodyComponent
impl<'de> Deserialize<'de> for RigidBodyComponent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RigidBodyComponent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RigidBodyComponent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for RigidBodyComponent
impl Serialize for RigidBodyComponent
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for RigidBodyComponent
impl RefUnwindSafe for RigidBodyComponent
impl Send for RigidBodyComponent
impl Sync for RigidBodyComponent
impl Unpin for RigidBodyComponent
impl UnsafeUnpin for RigidBodyComponent
impl UnwindSafe for RigidBodyComponent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
submit event.Source§impl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
Source§async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Source§impl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
Source§async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Source§impl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
Source§async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Source§impl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
impl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
Source§async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<CustErr, T, Response> IntoRes<Json, Response, CustErr> for T
impl<CustErr, T, Response> IntoRes<Json, Response, CustErr> for T
Source§async fn into_res(self) -> Result<Response, ServerFnError<CustErr>>
async fn into_res(self) -> Result<Response, ServerFnError<CustErr>>
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SerializableAny for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.