[Question] How do I prevent auto-deletion of projectiles spawned by level?

Updated Post:

After resolving my original problem, I wanted to pay it forward to the community with a little bite sized tutorial (really just a screenshot, with me answering any questions people have, if I can) on how to blueprint a “meteor shower” with projectiles into your level via a trigger (in this case the “/” key)!

I’ll probably update this OP with more things as I further develop this into a full event system, refine the scripting, add more variables in for randomization of the projectiles rotation/location/etc on spawn, once I learn more

If you have any questions feel free to ask, and if you have any advice to give, PLEASE DO. (I’m really new to UE4 still, but VERY hungry to be on the front lines so to speak, with the best of the best soon)

Screenshot of blueprint:

And video demonstration of it in use :wink:

Original Post:

Hi there,

I’ve successfully managed to blueprint in the starting mechanics for a “Projectile Emitter” in my level (using target points to spawn in a projectile), but here’s the problem I am experiencing currently:

All of the projectiles seem to get deleted at the same point in their life, before the explosion occurs on my projectile, despite any changes I make to their life span timers (meaning those awesome explosions I’m wanting to see shower down upon my level don’t have a chance to occur 95% of the time when they spawn in because I have them setup to explode on movement stopped).

It seems to be ignoring the delay of 40 seconds I added before destroying the actor in the script. I’ve also tried editing the projectile lifespan from 0 to anything else, and no dice.

I’m assuming just due to inexperience that I’m missing something silly, so any help would be appreciated!

Note: I’m using ShooterGame as a template for streamlining purposes, so the projectiles are based off the ShooterProjectile. Also please note, while I do not mind doing C++, just be aware & keep in mind, that I’m learning it still, and not very fluent with it at this point. I would prefer to work with blueprints where available.

Here’s the gist of the spawner blueprint in my level’s graph (note that the event is set to a keybind):

**Update: Well, I feel silly, I added “Set Life Span” right after the spawnactor, and that seems to have done the trick for now.

Update2: Now it is happening again. Weird. Haven’t changed any thing regarding lifespan or what not.

It was being inconsistent, now its not. Hmm.**

Not sure at this point where to look other than possibly the original ShooterProjectile C++ class (I’m guessing, and correct me if I am wrong here, that there is integer somewhere in there that is dictating the master life span of it)


  • Sinari

Can you show us the whole BP?
Delay is tricky sometimes.

e/ i’m pretty sure the template projectile got a lifetime set somewhere to some seconds

Yeah, but it’s going to be an hour or two at least, before I can SS anything in UE4 (at least…lol). Decided to put on Source Control for my game since I’ve made quite a bit of progress, and now I’m forever checking files into the source control.

Until then I can basically break it down for you how I have it setup currently;

Execute event on key “/” pressed -> Sequence shown in original SS + a few more pins on it now -> spawn actor (x10 overall, 1 per sequence pin to be exact, stemming from output of sequencer) (projectile), and then everything is the same from there on out, from each of the 10 pins on the Sequence. So basically just 10 outputs of the same projectile spawner, just with different targetpoints referenced.

It works fine all except for the projectile life (they all despawn at the exact same point in their lives, just not at the time I specify)

“x10 to be exact”
Are you you using the BP loop function? (for loop as an example)
That loop function screws up the delay. You have to make an own loop function.

Try it with 1 projectile, without the loop.

Sorry, when I originally posted that response I hadn’t clarified that part very well. x10 overall pin output(s) on the Sequence node is what I meant. Meaning 1 of that script happens per pin on the Sequence (1 projectile per target point with delay, and then after delay, then the deletion of the actor takes place, essentially is the setup for each sequence output). I’m not using a loop function at all with it. The only things not shown in that SS is the duplicates of the script from “Spawn Actor” and on for each of the outputs on the sequence node.

Here’s the SS, hopefully that clarifies things better than I could in text. Source control went much faster than anticipated :slight_smile:

PS: The projectile doesn’t even get to stop moving before it gets deleted, which my explosion is setup to take place when movement is stopped. Projectile works fine in my gun, and as intended, just not when spawned by the level.

My first thought was that your DestroyActor Target is self - the planet (i guess). But then i’ve seen that your original SS shows that DestroyActor Target was the Projectile.
So i guess that’s not the problem.
Are you sure that theres no Collision Event stuff in the projectile Class that’s destryoing it?
Make it simple, spawn the actor without set lifespan, delay, destory and see what happens.
If it gets destroyed, you’ll know that theres some other stuff in the projectile class.

e/ Like Event Hit -> Destroy Actor

Super Mini Tutorial on Projectile spawning on a level!

Alright, that’ll answer the question. If it’s in the core class i’ll just need to dig and find what is causing it and modify it. Thank you good sir :slight_smile:

Update: I feel really dumb right now and realized the issue. Just realized you we’re right on the notion that the actor target wasn’t actually the projectile. I had originally connected the nodes correctly, but I guess on accident had dragged them off at some point during duplication. Gonna have to be more careful next time.

Mini Bite Sized Blueprint tutorial to pay it forward :slight_smile:

It’s now working as intended. As a thank you, here’s a little example of how to create a “meteor shower” out of projectiles, on the level for those in the community still learning a ton as I am about UE4 and blueprinting :smiley:

If you have health and damage setup correctly on your pawn & projectile this will allow you to create spawn points to rain down hell on your level & characters/pawns (in my case projectiles that bounce till loss of movement and then explode)!

Possible uses: Event system for say a “meteor shower” in your game, arrow volleys for Matinee usage even, etc etc.

Example of blueprint setup:

Thanks again good sir for the help :slight_smile:

zomg so it was as simple as setting lifespan… In older versions of unreal no matter what I did it would still delete the projectile. I noticed the initial lifespan property actually works now, but thanks for making thread regardless.