Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@simonboots and I have implemented a fairly simple impulse-based "bomb" system, as part of the Rust Forge 2025 Bevy workshop.
A number of bombs may be statically placed in the scene.
The explosion is triggered by either an object colliding with the bomb, or being within the effective radius of another bomb when it detonates. The explosion radius is set by the constant
EXPLOSION_RADIUS
and can be tweaked, along with the explosion force defined byIMPULSE_SCALING
.An impulse force is applied to all objects within the explosion radius that have an
ExternalImpulse
component. Add one with:The force applied to any objects within the explosion radius is proportional to the distance of the object from the centre of the bomb. Then, a simple log-based non-linear function is applied to make the force apply more naturally by reducing the tailing-off effect as distance increases.
https://www.desmos.com/calculator/bd8bzvmi1w
Future improvements could include visual effects, a slight delay before detonation, and a small resilience to exploding so that objects need to hit it a bit harder to set it off.
bomb.png
is created by myself, using the Wingdings font, and I grant CC0 to this image.All code in this PR is hand-written by myself and @simonboots, and ChatGPT was consulted for help with triggers (bombs detonating bombs).