From e09b7d25370a7f25bbdb88ce4d9675b07f1231b5 Mon Sep 17 00:00:00 2001 From: Mitchell M Date: Mon, 2 Feb 2026 15:21:36 -0600 Subject: [PATCH] update movement --- assets/player.png | Bin 2114 -> 34 bytes src/avian.rs | 134 ++-------------------------------------------- src/main.rs | 19 ++----- 3 files changed, 8 insertions(+), 145 deletions(-) mode change 100644 => 120000 assets/player.png diff --git a/assets/player.png b/assets/player.png deleted file mode 100644 index 97557cd2f580fcf0aa5f4be7bea511fffa3241df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2114 zcmV-I2)*}-P)Ic7g#CSymUNOe|!k{tY9TgQ1E)Nh{bSzH$A(r=e=FS zKlx|&^{bhEUEN((U0oxx25V3xx+^yd3H_gNt@0`NcMs*u%JJpJ{{u?eI;DL_vHK5B z`L12!E9KA16P0%R6 zjMz+QGu8?TWT2<=JmvXfKkyOdOJbd9a&3(ME@D%dQNBXiPx-f)vYOnpn8vtF?7%f* zBYT2!h_X&hnRh5(6R@Ur4YGz|s#335mJLDUxqiMF(N&mtwB3Ryaq@ZC11lI!W8GNGyyc5a}O~O=7h2 zqL5Hd5Eip9s3;Js^834wLB`cT(gw^+D z$TCtFDAyGmy7Tg>1cD%N@O3m=Fn z`G@kiNfA0iCWu`fb^||7P_;Di9h;`Ej-4IxR%D8>F&I8()e4D#O5I>y zY^&T$dAssvF*nGDW>>LoGP8s15~KaFSm#PnD&B<|!;)Gg9T1x;CyMPIdS=Lx+$2X> ztt898XzN~}HMmeLjYaNoafTc=fz0vI88XpPv;vsYr;8nEObEzg2S~N;E7e#zK(_z^GvW9}Nj6z%CIFut!KR z7K&5==XXScABO}zaDr5|)88T$fIDMKF9`{HAOI@zcddq^{t=NMiHf|L<0Lo)saAwq zm;%@pauzr(B$xse7fP>1Ls1GKT~4}dUP#cx4q`dO&qIQ-P?Q32V>3fSDIkA9ifmFy zFcykX0NY>!nHeEL5A6EL8_@Z@aYMTVSsJE)YqLQ|i0%A_h6H1xh#A1CEx}A{a{Pd} zf#k@zkYG#{p#TgS2Oq6TbCX7+ROT6pl<3HdA{0=k+(azdkq7Mj?iR}sjS0v`M-c%B z`8xIi9C0_gD>DMu_O&C)ky0Lz^jN)XYt1=h6vWEIxno96l`qQn+ZNlMW(>)kJ_!}z@>HLCWA0V+nA`u^c4 z9c>UhJOvm$j>AWKa?}@a%)Xm+P*Bv&DDUI7Q%c8(Cv$u(0jkWBqs`d>HGtPk2L?~=$r8WJo#IDkz;LM|Vkn?gE9iTG1H}xUe;P#a zL#D_dX-est1w5~hR0%N@z;QK2lk-#B%k2oC6{{lY>$T$w3D2um2OL8Ij2QX+m5DY& z;0>jGbcX_127c8yOMqoFu*Dq(A%+47W2bm+gWYwqq=Tw3UVAx8EDM|j86n;gsLH!Q ztyKV)oobKn?lV~*EO#=6#WQ&`Y?fm=5dASz4)WTGC`pVCYH>#a$h#Rrjx#<28dBD! zcYwOMYqGkVJppU@O38k`g?E1_j%4S^4v}YaLX6TlQMy5zU&5MO<{1?uZ$98i<FcPL_a_n8nl)Oql}So}{2%zd0A5F!&-lB s@Fd+F`EAS!6uHW^m9A8&N68=j13}ZP0tShng#Z8m07*qoM6N<$f&%`=TL1t6 diff --git a/assets/player.png b/assets/player.png new file mode 120000 index 0000000..e413cde --- /dev/null +++ b/assets/player.png @@ -0,0 +1 @@ +/home/mitchell/Pictures/player.png \ No newline at end of file diff --git a/src/avian.rs b/src/avian.rs index 2992c45..90b879c 100644 --- a/src/avian.rs +++ b/src/avian.rs @@ -6,15 +6,7 @@ pub struct CharacterControllerPlugin; impl Plugin for CharacterControllerPlugin { fn build(&self, app: &mut App) { app.add_message::() - .add_systems(Update, ((keyboard_input, gamepad_input), movement).chain()) - .add_systems( - // Run collision handling after collision detection. - // - // NOTE: The collision implementation here is very basic and a bit buggy. - // A collide-and-slide algorithm would likely work better. - PhysicsSchedule, - kinematic_controller_collisions.in_set(NarrowPhaseSystems::Last), - ); + .add_systems(Update, ((keyboard_input, gamepad_input), movement).chain()); } } @@ -51,8 +43,8 @@ impl CharacterControllerBundle { character_controller: CharacterController, body: RigidBody::Kinematic, collider, - speed: MaxSpeed(100.), - acceleration: MaxAcceleration(1000.), + speed: MaxSpeed(300.), + acceleration: MaxAcceleration(5000.), } } } @@ -109,6 +101,7 @@ fn movement( for (max_speed, max_acceleration, mut linear_velocity) in &mut controllers { while movement_reader.len() > 1 { + warn!("Extra movement message. Ignoring"); movement_reader.read(); } @@ -128,122 +121,3 @@ fn movement( **linear_velocity += delta; } } - -/// Kinematic bodies do not get pushed by collisions by default, -/// so it needs to be done manually. -/// -/// This system handles collision response for kinematic character controllers -/// by pushing them along their contact normals by the current penetration depth, -/// and applying velocity corrections in order to snap to slopes, slide along walls, -/// and predict collisions using speculative contacts. -#[allow(clippy::type_complexity)] -fn kinematic_controller_collisions( - collisions: Collisions, - bodies: Query<&RigidBody>, - collider_rbs: Query<&ColliderOf, Without>, - mut character_controllers: Query< - (&mut Position, &mut LinearVelocity), - (With, With), - >, - time: Res