pub struct RigidBody {
pub gravity_scale: f32,
pub capsule_radius: f32,
pub capsule_height: f32,
pub jump_height: f32,
pub max_slope_deg: f32,
pub step_height: f32,
pub is_grounded: bool,
}Expand description
Gives a player Camera3D gravity, jumping, and a grounded character body.
Every Camera3D already collides with the world as a capsule. Adding a RigidBody upgrades that camera from a free-flying spectator to a grounded character: it falls under gravity, lands on surfaces, climbs steps, slides off steep slopes, and can jump. The capsule size is configured here too.
{ "name": "player_body", "type": "RigidBody", "args": { "jump_height": 1.4 } }Fields§
§gravity_scale: f32Multiplier applied to the global gravity constant. 1.0 = normal gravity.
capsule_radius: f32Radius of the player capsule used for collision, in world units.
capsule_height: f32Total height of the player capsule. The camera eye sits at the top.
jump_height: f32Apex height of a jump in world units. 0 disables jumping.
max_slope_deg: f32Steepest slope the player can walk up, in degrees.
step_height: f32Tallest obstacle the controller auto-steps over, in world units.
is_grounded: boolTrue when the capsule is resting on a surface this frame. Written by PhysicsSystem.
Trait Implementations§
Source§impl Component for RigidBody
impl Component for RigidBody
Source§const NAME: &'static str = "RigidBody"
const NAME: &'static str = "RigidBody"
Source§fn from_baked(bytes: &[u8]) -> Result<RigidBody, CnResult>
fn from_baked(bytes: &[u8]) -> Result<RigidBody, 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 RigidBody
impl ComponentSlot for RigidBody
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§impl<'de> Deserialize<'de> for RigidBody
impl<'de> Deserialize<'de> for RigidBody
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RigidBody, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RigidBody, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<RigidBody> for ComponentAsset
impl From<RigidBody> for ComponentAsset
Source§fn from(c: RigidBody) -> ComponentAsset
fn from(c: RigidBody) -> ComponentAsset
impl RuntimeComponent for RigidBody
Source§impl Serialize for RigidBody
impl Serialize for RigidBody
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 RigidBody
impl RefUnwindSafe for RigidBody
impl Send for RigidBody
impl Sync for RigidBody
impl Unpin for RigidBody
impl UnsafeUnpin for RigidBody
impl UnwindSafe for RigidBody
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>,
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 moreSource§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,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().