So I’m building a Crash clone and I’m currently working on adjacents for the TNT blocks. I can get them to explode, but I want them to stagger slightly so they detonate in sequence as opposed to all blowing up at once. I followed a UE4 tutorial, but I had to work out for myself when the code didn’t execute 1:1. Does anyone know a way to work in a delay so there’s a nice “chain reaction” effect?
Here’s some screenshots of all the code relating to the explosive crates only:
What I would do:
- make the crates detonate immediately when receiving (enough) point damage
- make the crates set a first 0.1 second timer when receiving (enough) radial damage from nearby
- make the crates set a second 0.5 second timer when receiving (enough) radial damage from further out
- make each timer detonate the create if it isn’t already detonated
This means that you can place the crates in an artful way to case slower or faster cascades, and a player can still shoot/impact/hit a crate to make it immediately explode.
Exactly how far “nearby” versus “not nearby” should be, and what the damage levels are for “enough,” is up to you.
Correct me if I’m wrong, but the first thing I need to do is remove that delay from the “completed” output of the each loop node, right?
I think you need to re-factor a little more.
Currently, you’re applying damage to all impacted objects right away, from the initial breaking event. You’ll want a delay in the “apply damage” → “actually explode” cycle. Except you don’t want that in the case the damage comes directly from the player. In my suggestion above, you separate these out, by making explode damage be radial, but player damage be point damage. You can also use damage types to achieve the same effect.
The “delay then destroy actor” just lets the actor stay in world for a little bit; it’s the same as setting the actor lifetime to some positive number.
Thanks for the input, but I had a eureka moment thanks to a colleague. He suggested adding a delay to the “AnyDamage” node, and I added to it by inlcuding a boolean to separate the damage to explosive crates from the damge to normal crates
Yup, something like that!