Spawning Parent and Child Projectiles?

Hi everyone,

My terminology may not be appropriate, but how would I go about spawning a parent (or main) projectile that then spawns child (or sub) projectiles? Basically, I’m trying to achieve the following game-play functionality: a grenade launcher that shoots a large grenade, which upon exploding, shoots several smaller grenades (in random directions) which also explode. So basically, I need to know how to spawn multiple projectiles and then adjust the rotation for each. I’m assuming this is where scary programming terms like arrays and loops come into play? I would greatly appreciate being pointed down the right path.



I gave this a try. I took the FPS template and modified the MyProjectile blueprint.

First I added an IsChild boolean variable to it, with default value false. So when the player shoots a projectile, it’s considered a parent projectile.

Then, I expanded the MyProjectile blueprint’s graph. In the Event Hit that is implemented by default, I check if the projectile is a child. If it isn’t, then I know I have to spawn some children. I do that in a simple loop. I just take the location of the parent, and add a random vector to it, so the children are spawned randomly around the parent.

Finally I make sure that the children have their IsChild variable set correctly, otherwise the chilren would spawn other children on their own Event Hit, and you get a nice infinite loop and crash.

Hi Bajee,

Thanks for your reply and nice work on getting the Blueprint functional. I want the behavior of my Blueprint to be a little different from yours. I want the larger grenade to spawn the smaller grenades after a delay (as opposed to on a hit event) and I want the smaller grenades to shoot out with velocity, but with varying pitch/yaw with a positive Z axis value (so that they don’t fly directly into the ground). I didn’t explain this very well in the original post. Currently, I have the Blueprint semi-functional. The smaller grenades appear to be spawning, but are doing so under the ground geometry. I’m going to continue working on it. Basically, I have three Blueprints: MyCharacter, BigGrenade, and SmallGrenade. MyCharacter spawns one instance of BigGrenade, and then BigGrenade spawns multiple instances of SmallGrenade. I’m unsure if this is the most efficient approach.

You could just add a delay node before you spawn the child projectiles. And modify the random vector to only have positive Z values.

Hi Bajee,

I’ve tracked down what the issue is, I just don’t know how to resolve it. It appears that the collision mesh on the small grenades prevents them from dispersing correctly. If I turn the collision off (or set it to custom and to overlap projectiles), then it works OK, but obviously then the small grenades don’t interact correctly.

Do you spawn them all at one place? If so, they probably collide with each other immediately and disappear (or what ever you programmed for the small grenades’ collision)

Yeah, they’re all being spawned from the same location. I’m unsure on the best method to randomise the spawn location for the smaller grenades (8 units diameter, ~150 in quantity) but retain the illusion of them coming out of the larger grenade (80 units diameter).

Hello there,
keep in mind that once a projectile overlaps another projectile it will send an impulse to the other projectile,
In your collision component you can set it to “initially” ignore and “afterwards” set it back to blocking:

The important bit is that the object type is set to *projectile *and collision response to ignore.

So that should prevent the projectiles from affecting one another when they spawn.
If you’d want your projectiles to interact with each other there are many ways to go about doing that,
but to keep it simple you can use a Timer or calculate time in the Tick event, like so:

It’s alive! Big thanks to both of you for pointing me in the right direction. :slight_smile:

Really super job! The coolest thing I’ve seen done in Unreal today!! I’m trying to do the same thing but have my enemies split in 2 or 3 pieces after being hit by a projectile. Any tips? :slight_smile: :slight_smile:

Really super job! The coolest thing I’ve seen done in Unreal today!! I’m trying to do the same thing but have my enemies split in 2 or 3 pieces after being hit by a projectile. Any tips?

could u elaborate on this? i copied your blueprint but in my last stage there, on the “set”, it doenst have a “target”. its just 2 red dots. and when it hits on the impact the sphere turns into over 3000 spheres which i suspect is causing my game to crash. O_o how to lower the amount of children??

here is a picture. as you see at the far right, there is no “blue” option at the boolean. so where should i put the return value?


Oh, in Bajee’s version IsChild boolean is a member of the projectile blueprint. However in your version, IsChild belongs to the blueprint event graph of which you are currently in. He sets another blueprint’s variable, hence there is a target input.

i figured it out! what a noobie mistake. :smiley: just drag out the “Returnvalue” and then click “set” from that. for some reason if i do it the other way around that blue little box doesnt show up. now i have new problem tho. how can i modify the transformed vectors more? right now the ball is flying into the wall, and exploding, and coming right back at my face. :smiley: i want it to be able to change its initial velocity, and lifetime, and so on and give it particle emitters!

edit: fixed. added a “lifetime” to the blueprint. and i supposed o could find some velocity thingie to change initial velocity. now im going to try to make it so that it only explodes on a certain material. so that if i shoot the projectile through glass it doesnt explode. but if i shoot on steel it does explode. and if i shoot onto steel that is behind glass, etc. any help be amazing. if anyone reads this! =D