Hello again, I was wondering if anyone could help me out with an issue I’m having regarding respawning a destroyed object.
To elaborate, I’ve been trying to make an object that when destroyed, would then respawn a couple of seconds later. In order to accomplish , I created a spawner blueprint that would spawn the desired object; so far so good.
The problem though is that I’m not sure how to handle the respawning part, as I’m not sure how to communicate to the spawner blueprint that the spawned object has been destroyed, so that a new object could then be spawned in its place.
Does anyone have any idea on how can be done?
Any help whatsoever would be greatly appreciated! Thanks in advance!
communicate to the spawner blueprint
that the spawned object has been
destroyed, so that a new object could
then be spawned in its place.
Like , actors come with a bunch of useful dispatchers:
So it could look like so:
would trigger only if the current actor gets destroyed, wait 1s, spawn another and re-register the dispatcher.
Side note - depending on what you’re doing, there may be no need to destroy the actor. Games are smoke & mirrors. Perhaps it’d more convenient to Hide & Show rather than Destroy & Spawn, which can be costly if we’re talking many actors.
Ofc, may not apply as you may want a totally different actor. Just a thought!
Alternatively you may want to add your own custom dispatcher to the spawned actor if you want to communicate very specific data back to the spawner.
And, most importantly, does not actually need hard references at all (NewVar0) - a great advantage of the dispatchers.
Okay, I finally got it working with your suggestion.
Thanks again for the help!
I don’t know what you mean by clearing the reference. I tried doing a Google search for “clear reference” but I couldn’t come up with anything of help so instead I just made a educated guess based on your screenshot. It worked so I thought that I guessed correctly but evidently I was mistaken. In which case, then what is node?
It looks like the ‘Set Variable’ node although not quite the same and I can’t find it anywhere.
One note - you were supposed to clear the reference after the Respawn Balloon node (see my node comment - set it to NULL). What you’re currently doing there is a tad strange, setting the reference of an actor to the very same actor that does no longer exist - potentially catastrophic.
Technically, you can omit step; the reference is invalid anyway once the actor gets destroyed. It’s just good practice to ensure those pointers point at nothing. To make things transparent, safe and obvious to others.
Unplug and let it be:
You should end up with:
Now we’re certain variable is not associated with any actor (including the one being Destroyed!) unless a new one spawns and the value is assigned again. It’s just good practice in case an actor gets lost - makes debugging easier when things get complicated.
Somewhat similar to :
Okay, that worked, although my version still doesn’t look like the one in your screenshot.
It’s fine, it’s probably world context. I must have dropped the example in the LB, sorry for the confusion. It’s all fine, though. Much better disconnected.
Good luck with the rest!