pub struct PropBody {
pub prop_name: Option<AssetId>,
pub mass: f32,
pub friction: f32,
pub restitution: f32,
pub gravity_scale: f32,
pub linear_damping: f32,
pub impact_clip: Option<AudioClipHandle>,
pub impact_volume: f32,
}Expand description
Makes a companion Prop a dynamic physics body.
Attach a PropBody to give a Prop real physics: it falls, collides,
stacks, tumbles, and (with pickup: true on the prop) can be carried and
thrown. A Prop with a collider but no PropBody is a static, immovable
obstacle.
{
"name": "crate_a_body",
"type": "PropBody",
"args": { "prop_name": "crate_a", "mass": 4.0, "friction": 0.6 }
}Fields§
§prop_name: Option<AssetId>The Prop this body drives. Must match a Prop declared in the same world.
mass: f32Mass in kilograms. 0 lets the simulation derive mass from the collider shape and a default density.
friction: f32Friction coefficient used for contacts with this body.
restitution: f32Bounciness in [0, 1]. 0 is fully inelastic.
gravity_scale: f32Multiplier applied to world gravity for this body. 1.0 is normal.
linear_damping: f32Linear velocity damping, modelling air drag.
impact_clip: Option<AudioClipHandle>Optional AudioClip played at the contact point when this
body collides hard enough to pass the world’s contact_min_impulse
(see PhysicsConfig). Louder impacts play louder.
impact_volume: f32Linear gain applied to the impact clip at full impulse.
Trait Implementations§
Source§impl Component for PropBody
impl Component for PropBody
Source§fn from_baked(bytes: &[u8]) -> Result<PropBody, CnResult>
fn from_baked(bytes: &[u8]) -> Result<PropBody, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for PropBody
impl ComponentSlot for PropBody
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§impl<'de> Deserialize<'de> for PropBody
impl<'de> Deserialize<'de> for PropBody
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PropBody, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PropBody, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl RuntimeComponent for PropBody
Source§impl Serialize for PropBody
impl Serialize for PropBody
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 PropBody
impl RefUnwindSafe for PropBody
impl Send for PropBody
impl Sync for PropBody
impl Unpin for PropBody
impl UnsafeUnpin for PropBody
impl UnwindSafe for PropBody
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
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 more