fishfolk / jumpy

Tactical 2D shooter in fishy pixels style. Made with Rust-lang 🦀 and Bevy 🪶
https://fishfolk.org/games/jumpy/
Other
1.6k stars 115 forks source link

feat(physics): Support Dynamic bodies #927

Closed MaxCWhitehead closed 4 months ago

MaxCWhitehead commented 4 months ago

This is the base of core changes to support ragdolls, allows us to simulate dynamic bodies in rapier.

DynamicBody component may be added to an entity that has KinematicBody, and if enabled, body will simulate physics. Transitioning between kinematic / dynamic and adjusting rapier data + collider is handled on next physics update.

This change should have no impact on existing kinematics, scene queries, etc. Usage of these changes will come in other PR soon.

Switched to fork of rapier (temporarily hopefully): I switched us to a fork of rapier to fix a bug in which changing a rapier rigidbody from kinematic to dynamic will not put it in active dynamic set, so gravity is not applied. It seems they rely on contact graph to add body to this set, but if not in contact with anything it breaks. I have a PR open for a fix in rapier.

Some notes on changes:

There's a decent chunk of physics stuff in collision module now, at some point maybe should detangle this, but probably fine for now. I renamed some functions to make things more clear.

MaxCWhitehead commented 4 months ago

Nice. I like how small this diff is. 🚀

There's more haha but going in logical chunks at least so it's not a massive change soup :)