Skip to content

Conversation

DavidAntliff
Copy link

@DavidAntliff DavidAntliff commented Sep 3, 2025

@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 by IMPULSE_SCALING.

An impulse force is applied to all objects within the explosion radius that have an ExternalImpulse component. Add one with:

ExternalImpulse::new(Vec2::new(0.0, 0.0)),

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).

@extrawurst
Copy link
Contributor

Awesome work! Can you rebase and place the bomb in the second house so the second shot is needed to set it off?

Great job!

@DavidAntliff
Copy link
Author

Can you rebase and place the bomb in the second house so the second shot is needed to set it off?

Sure, will do this as time permits. I also have some improvements to bomb sensitivity, fuse timing, and also making it move similar to a crate, rather than being stuck in space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants