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<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, 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.