Download

Can't seem to spawn an object after its destruction

Sorry for bad wording here. Trying to explain as much as I can.

I’m trying to spawn a DM (Destructible Mesh) object after destroying another DM.

Here’s what I’ve done.

1: Create Static Mesh
2: Create Destructible Mesh
3: Create Blueprint From Destructible Mesh
4: Spawn Destructible Mesh Blueprint in game on “Event BeginpPay” (Inside of my gamemode blueprint) (this works)
5: Destroy Destructible Mesh and have another spawn (this doesn’t work)

That’s it! That’s all I want to do. But Unreal isn’t letting me target this for some stupid reason. I’m having issues calling my destructible mesh because I can’t seem to figure out a way to get it to spawn.

I want to destroy a destructible mesh that I’ve created a blueprint for. After it gets destroyed I want it to spawn another one. However, I can’t seem to figure this out.

SO… When I go into my level blueprint and try to figure out a spawn script to get these destructible meshes to spawn, i can’t get the BindEventOnDestroyed to target anything except for “self” and I can’t seem to figure out how to get this.

Could Someone help me spawn a destructible mesh after destroying another one?

When using “Bind Event To OnDestroyed” it will only reference its “self” as seen here.
wbNh3Pi.png

However you can see here it’s not actually referencing the right actor. since this has to be in my level BP right?
What it seems like it wants me to do is to put this script in the object blueprint. So I tried that. I’m stuck lol. I just keep taking steps backwards.

This is the object I want to destroy. This spawns when the game starts. Works just fine. However, I want to destroy this object in game and have it spawn a second, third, fourth, etc.

5496d33f71b4d735374bb6e846b6981eda9d87aa.png

So I tried to go into the DM Blueprint I created for my destructible mesh to have this spawn another object. Now obviously, this is wrong. . Since it’s not working haha. But I wanted to show what I’ve done. I’ve also tried to do this in my level BP but I can’t seem to figure it out there either. So I either need to call this spawn in my DM BP, or my level BP, and I can’t seem to figure out how to get it to work in either.

JWnbn6i.png

**
Maybe someone make a box or a quick DM and run me through this? After destroying a DM, it spawns another DM.**

Once it is destroyed, it stops running code and stuff (because it has been destroyed). Try spawning before destroying.

Don’t I want the actor to be destroyed?

If I run code before the actor is destroyed it defeats the purpose of what I’m trying to accomplish. (I think at least) I want the actor to get destroyed after shooting it. I want the next object to spawn after the first one gets destroyed. After it gets destroyed I’m having an issue getting it to call the spawn function correctly. I’ve tried and attempted this in every way I know how to. That’s the issue I’m having. lol. Even if I run it before the “destroy Actor” I’m still unsure of how to do that I guess.

You can see that the object is given a set amount of health. That much works. After it takes that amount of damage it’s destroying properly. However the issue I have is after that. I think it’s bugged perhaps?

Even as the way this is written out now, it should work. I just don’t see where the problem is lying. You’d think it’d be simple but it seems like it may be bugged. The blueprint makes perfect sense to me in the last screenshot. I just can’t see why it’s not working i guess.

Could it be possible that my projectile isn’t causing the objects “OnTakeAnyDamage” event to not fire? Just to be sure here’s a look at my projectile BP. (Nevermind the destroy actor node just sittin there, cleanup hasn’t happened yet)

6205ba6cab70674f6f3b590cdc49ba0bdb377b60.png

It is destroyed, thus wiping out any and all actions that occur after the destruction. The Engine is no longer computing the destroyed actor. You would put your spawn node right before the destroy node.

I don’t have the Engine in front of me, this laptop is not good for it, but I’m fairly certain that’s how it works. Once it’s destroyed, it’s gone. Game Over. Hasta La Vista. Sayonara. It’s written 0 bit markers on that part of the hard drive.

Destroy should be the last node on the line.

Interesting. Well I tried this…

I ran a “play2d Sound” node right after the branch. It’s not firing at all. Just to test what’s going on here. You can see here.
6fa9b56128ada3fc08f59518f4d82fedf741898c.png

So What’s weird is that my projectile is working, and it seems that my health indication for the object I’m trying to destroy is fine. I went into my DM properties and set the damage threshold to 100 and it’s taking 5 shots to get it to destroy. Which is exactly where it should be since the radial damage on my projectile is 20. So it seems that “OnTakeAnyDamage” event is working with the health indicators I have set. HOWEVER, when the object finally does break after the 5 shots, it doesn’t fire the sound I put in to test it.

8ca245dea5b363711d27070d89adce86ae561efb.png

According to the blueprint, it should play the sound every time it takes damage except when it’s “Health” is lower than 0, so technically it should play the sound 5-6 times. I’m not sure if Play Sound 2D is the correct node you want. Play Sound At Location, maybe?

Also, move the connection to the False on the Branch or make the >= into a <= sign to make the sound and spawning function on “death” of the Asteroid1_DM_BP.

FIXED!!

Here was the solution. I had the wrong event Damage actor. That’s literally all I did. The spawns are working as well as the sound test. I added an “Event AnyDamage” node, and ran it the same way… Not sure why this one works but the other didn’t. I spent days trying to figure this out. Thanks for the help YGG. Appreciate it!!!
9nDM6e5.png