bevy_xpbd icon indicating copy to clipboard operation
bevy_xpbd copied to clipboard

Add `CustomGravity` component

Open Pyxrs opened this issue 9 months ago • 1 comments

Objective

Some users may want gravity to affect bodies differently, such as for Newtonian gravity or other nonstandard applications of Avian. GravityScale exists, but it is a very limited solution.

Solution

I added a CustomGravity component that overrides the Gravity resource if it is present on a body.


Changelog

  • Added: CustomGravity
  • Added: custom_gravity example (based on many_shapes)

Pyxrs avatar Mar 10 '25 13:03 Pyxrs

Looks like fmt messed up the diff, the only changes to the integrator module were on updated lines 210 and 244.

Pyxrs avatar Mar 10 '25 14:03 Pyxrs

Hi, thanks for the PR, and sorry for not responding earlier :sweat_smile:

I think this is a bit too niche in terms of the scope; fundamentally this is about a component to apply a constant linear acceleration to bodies. This doesn't necessarily need to override gravity (you could set GravityScale to zero if you did want that).

I just merged #770, which overhauled our force APIs and integration logic, and also included a ConstantLinearAcceleration component. It seems like that component fills the same need as this PR while being a bit more general. So I think I'll close this in favor of that :)

Jondolf avatar Jul 17 '25 15:07 Jondolf