-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Independent Forces using the ExternalForce
component
#477
Comments
That's the result both of the examples are trying to achieve. The assumption here is that the thruster vector and gravity vector aren't initially available in the same system, so they can't be added together directly unless an extra system and extra components are used. In my case, the gravity vector would be coming from a complex gravity simulation managed by one plugin, and the thruster vector would be coming from another plugin/system. It would be nice to find a solution that allows the gravity code and the thruster code to remain separate so that they're modular. My |
If you want it to stay "modular" and easy to understand, what you did is just perfect.
The only faster way you can have is to put every force calculation in the same system, a big and confusing system (I didn't even think about that when I suggested my solution). PS : not even sure if the system is too big |
I'd like to be able to add independent forces/impulses together somehow. For example, I'm working on a space-themed game that requires both the force of gravity (calculated using an n-body simulation) and the force from thrusters to be applied to the same entity (the player's ship). However, this seems to be non-trivial.
It would be nice to be able to do something like this:
This doesn't work because the force isn't reset every frame. Instead, the force compounds. To fix this, it's possible to manually reset the force to zero; this might actually be the best option since this allows systems in any part of the code base to add to the total force. Here's a plugin that I wrote that implements this:
Another method: you could create a component for each source of force, and then use a system to combine the forces.
Is there a better, more ergonomic way to do this with bevy_rapier's APIs?
The text was updated successfully, but these errors were encountered: