I’m creating doom like mechanics, and I want the explosive barrel I have that already causes damage to me to damage other barrels that are in the radius to cause a chain reaction of explosions like it would it the actual game doom.
I think it has to do somewhat with object types in the Multi Sphere Trace For Objects, but I don’t understand how to make it include actors that are just the barrels.
Right now the barrels are only able to cause damage to the player and to the enemies if they are in the radius when it blows up.
So, you are filtering your trace to only include objects of type “pawn”. I’d assume your barrels are something different, most likely “WorldDynamic” or “PhysicsBody”. Check in the barrels class settings.
Any reason why you aren’t using “ApplyRadialDamage(WithFalloff)”? That one wouldn’t filter out anything.
The reason I didn’t use “Apply Radial Damage With Falloff” is, I didn’t know it existed. I used a course that helped me make this project to this point and to understand more about game dev.
There’s some things I don’t understand yet so I came here so bare with me.
anyhow, my barrel is an actor. also, the radius became green when I set it to World Dynamic. So progress.
Don’t get me wrong, both cases can be totally valid. It’s just that you’re kinda reinventing the whell here, but maybe doing collision was actually the goal of the tutorial. Additionally when you’d switch to a more advanced system like GAS you would most likely do the sphere trace and fall off calculation on your own as well.
So is it working for characters and barrels now? Or just one of them?
I’m sure there’s a better way to do this and I’ll look into GAS later. But I would like to make this work, as a learning experience if nothing else.
When the barrels get destroyed, it marks where they are in the radius area but it doesn’t actually take damage when others explode nearby it. I still take damage and so do my enemies though.
inside your BP_Exploding_Barrel Blueprint details, try setting your Collision Preset for Box to Destructible. This will change your Object Type to Destructible. Then add Destructible to your Types of Objects Acceptable array along with Pawn.
Also, for the BP_Exploding_Barrel BP root, check that ‘Can be Damaged’ is checked true. I think it usually is by default but if it isn’t that Event AnyDamage won’t get called.
I did that. Can be Damage was set to true. I set my barrels to destructible and added destructible to object types in the barrel bp. at first it wasn’t taking damage so I looked into my base weapon bp that all my weapons inherit from and that was working in a similar way with acceptable object types and added destructible to that too.
But when I went to shoot my barrels after this, the others did get damage applied that’s what all those zeros are in the print string but the game crashed a second later saying I had an infinite loop going on.
So I was watching a video by ryan laley to understand how Apply Radial Damage works. pladax was 100% right that I was doing it the hard way. I think trying to filter for specific objects twice was causing all the issues.
For some reason you have to destroy the barrel before it applies radial damage. I think the game was adding damage to itself before destroy it and it was not about it.
I wouldn’t have gotten this point without yall though. thank ye kindly.
I wouldn’t recommend doing anything with an actor after it’s been destroyed.
What’s likely happening: You destroy the actor, then call ApplyRadialDamage with “Self” as the Damage Causer. The engine passes this already-destroyed reference to the ReceiveAnyDamage events of nearby actors. It works in your case because you’re not actually using that reference, but if you tried to access it, you’d get errors (“object is pending kill” or “accessed None”). Even if it technically works, it’s poor practice and can lead to unpredictable behavior.
Better solution: Call ApplyRadialDamage before DestroyActor, and add “Self” to the “Ignore Actors” array so the barrel doesn’t damage itself.
This ensures all references are valid when the damage is applied and follows proper actor lifecycle management.
good to know. I did that, now the actor is being destroyed after the “Apply Radial Damage” excluding itself, but I kept getting this error that there was an Infinite Loop going on with “Event Anydamage”.
So I put my delay before “Apply Radial Damage” and it worked fine. Not sure why that was happening but I’m glad it works better this way.
The infinite loop before you added the delay was because you would call AnyDamage with a hit, then it would ApplyRadialDamage, then it would call AnyDamage, then it would ApplyRadialDamage, on and on…
To fix this, you add reference to ‘self’ to an array that gets plugged into the ApplyRadialDamage Ignore Actors pin.