bevy_fps_controller icon indicating copy to clipboard operation
bevy_fps_controller copied to clipboard

Add `avian3d` support

Open chompaa opened this issue 1 year ago • 1 comments

This PR adds support for avian3d via the avian feature. Here's a list of changes:

  • Add a controller_avian module and minimal_avian example, feature gated behind the avian feature.
  • Move the controller to controller_rapier and minimal example to minimal_rapier feature gating them behind the rapier feature.
  • Add a controller module that reexports both controller modules, so you can still import with use bevy_fps_controller::controller::*

I think there is a bug with overhang_component in controller_avian, since edge fall prevention doesn't seem to be working 100% of the time -- I couldn't crack this unfortunately. My (minimal) testing has shown identical behavior otherwise.

I understand that this is a large diff, so if you'd like a different approach I'd be happy to comply.

chompaa avatar Jan 05 '25 08:01 chompaa

Woah nice! I will take a look, thanks

qhdwight avatar Jan 05 '25 20:01 qhdwight

Hey - mind rebasing?

qhdwight avatar May 18 '25 20:05 qhdwight

Hey - mind rebasing?

Hey! I'll try to get around to this in the next few days :)

chompaa avatar May 18 '25 21:05 chompaa

Thanks. I rebased and fixed up the compilation in the avian branch for my own testing.

It seems like it is a little bit choppy? Can you see this on your end?

qhdwight avatar May 18 '25 22:05 qhdwight

Also - I think we should seek to minimize copy and paste by sharing common functions among both features that are the same.

i.e. fps_controller_look fps_controller_input FpsController, etc.

That way when we update, the pain is minimized.

qhdwight avatar May 18 '25 22:05 qhdwight

I think there is a bug with overhang_component in controller_avian, since edge fall prevention doesn't seem to be working 100% of the time -- I couldn't crack this unfortunately. My (minimal) testing has shown identical behavior otherwise.

I am also seeing this too. Seems like this line is to blame:

// Make sure that this is actually a ledge, e.g. there is no ground in front of us
let cast = spatial_query.cast_ray(
  future_position + Vec3::Y * 0.125,
  Dir3::new_unchecked(-Vec3::Y),
  0.375,
  false,
  &filter,
);

Sometimes I can get stuck on the ledge when crouching and can't move at all. I would expect the above to return Some, but it returns None instead. The ray origin and direction looked good, so I am confused.

qhdwight avatar May 18 '25 23:05 qhdwight

Closing in favor of #53

Will come back to these other issues

qhdwight avatar Aug 31 '25 21:08 qhdwight