INNER CODE UNIT · Rust
collider
dust-engine/dust · crates/character/src/lib.rs:142
pub fn collider(&self) -> Collider {
Collider::capsule(self.radius, (self.height - 2.0 * self.radius).max(0.0))
}
/// Eye position for a character whose capsule centre is at `translation`.
pub fn eye(&self, translation: Vec3) -> Vec3 {
translation + Vec3::Y * (self.eye_height - self.height * 0.5)
}
/// Look rotation from `yaw` and `pitch`, looking down -Z when both are zero.
pub fn look_rotation(&self) -> Quat {
Quat::from_euler(EulerRot::YXZ, self.yaw, self.pitch, 0.0)
}
}
/// Marks the entity whose [`Transform`] follows the character `0`'s eyes and look angles.
#[derive(Component, Clone, Copy, Debug)]
pub struct CharacterCamera(pub Entity);