diff --git a/src/player.rs b/src/player.rs index bad44e4..7ffc50f 100644 --- a/src/player.rs +++ b/src/player.rs @@ -1,13 +1,10 @@ -use bevy::{ - input::mouse::MouseMotion, - prelude::*, -}; +use bevy::{input::mouse::MouseMotion, prelude::*}; use bevy_rapier3d::{ na::{clamp, wrap, Matrix3x1}, - physics::RigidBodyHandleComponent, + physics::{ColliderHandleComponent, RigidBodyHandleComponent}, rapier::{ dynamics::{RigidBody, RigidBodyBuilder, RigidBodySet}, - geometry::ColliderBuilder, + geometry::{ColliderBuilder, NarrowPhase}, }, }; use std::f32::consts::{FRAC_PI_2, PI}; @@ -73,16 +70,40 @@ fn init_player(commands: &mut Commands) { }); } +// TODO: this is incomplete, currently just checks that the player is touching anything +fn is_on_ground( + narrow_phase: &Res, + collider_handle: &ColliderHandleComponent, +) -> bool { + if let Some(n1) = narrow_phase.contacts_with(collider_handle.handle()) { + for _n2 in n1 { + return true; + } + } + return false; +} + fn player_movement_system( time: Res