For this assignment, we needed to create a sort of missile.
I was thinking of earthbending, and then wanted to see if I could copy static meshes from the environment into a Niagara system.
This project was a practice in communicating back and forth between blueprints and Niagara systems.
Static meshes within a radius of the player/RockCast blueprint are selected and filtered for the "rock" tag. Each rock's transforms, bounds, and mesh name are saved to arrays that get set to a Niagara system.
Communicating which mesh to use in Niagara was trickier- in 5.5, there is no node option for static meshes arrays (I don't know if the 5.6/5.7 option would work the way I wanted anyways.) Instead, since the static meshes for the rocks I was using were named 00#, I just used the last digit as an index/id.
To actually spawn my particles with the right amount and place, I used a scratch module in Emitter Update to spawn in the amount of particles based off the length of one of my arrays.
And in Particle Spawn, another scratch module to set position, rotation, and scale. I had to set age because otherwise it didn't exist and Niagara didn't like that.
I was not able to figure out a way to copy any static mesh in the world over to Niagara. Instead, I created an array of meshes I expected to be copying over in the Mesh Renderer. Inside Initialize Particle, which index from the array it samples is decided by my MeshID array.
With the static meshes copied over, I could raise them into the sky easily and group them together with a Point Attraction Force instead of using animation timelines in the blueprint.
As the rocks lifted up in to the air, I needed dust to spawn around each rock and rubble and dirt to fall down.
I do it with Spawn Particles from Other Emitter and Sample Particles from Other Emitter.
But! Each rock has a different size, so all the dust and rubble's spawn locations need to match that. In Particle Spawn, I set a new attribute called RockIndex copied from Sample Particles From Other Emitter (the particle index from the original rocks) so all dust and rubble can match to its "parent." I make a new attribute because I need an integer for the next step, while the original attribute is a float.
I will continue to focus on dust here- I spawn it in a ring around each rock. Since each rock can be a different size, I turned the bounds of each rock into an array named RockCloudRadius.
For each ring that gets spawned, the emitter reads what RockIndex it has, then gets the corresponding radius from the RockCloudRadius array.
Originally I wanted all the rocks to group in the middle and have self collision- then get "crushed" for the actual projectile. I found a tutorial but couldn't get it to work, but I tried something different in the end.
Point Attraction Force has an option to kill particles that hit the center area. Niagara Emitters can have events based on things such as Particle Death, which can be communicated to other Niagara Emitters in the system and blueprints. I wanted a spray of dust and rubble to spawn when those rocks were killed.
In Particle Update on my rock emitter, I added Generate Death Event. In my dust+rubble sprays, I added a Stage for an Event Handler- and selected my rock's death event.
To send these events to a blueprint, I added Export Particle Data to Blueprint. I created a user parameter of type Object for the blueprint it needs to refer to, and in my blueprint set the parameter to self.
Then to create the actual event in the blueprint, go to Class Settings, add the interface, go to the left of the screen where the interface has been added, right click and hit Implement Event.
I used this to scale up the rock projectile's size every time an original rock got killed.
Rocks: Quixel
Smoke + Rubble : https://www.fab.com/listings/ac2818b3-7d35-4cf5-a1af-cbf8ff5c61c1