I wanted to do fish swimming along a spline.
I made a blueprint for my spline to be stored in along with a Niagara component using my particle system. In a function activated by construction script and EventBeginPlay, I forward the spline to the Niagara system as a variable. Also because I want to make this a gpu particle system, I need to set the bounds myself.
Trying to get spline component bounds does not appear to work inside a level. Actor bounds do not account for the spline in this situation either. The solution I am currently using converts the spline into polygons and samples the bounds from that. It partially works- However the bounds from this are missing one axis, which I still have to set myself right now.
I spawn a static mesh of a fish with the Mesh Renderer and set Facing Mode to Velocity. Later I'm going to edit the material to create a swimming animation with WPO.
Scratch pad modules are like blueprint functions. They're custom modules we can make and add to the Niagara emitter that only exists local to that specific emitter.
This first one here samples the spline and goes before the Shape Location module. This way, the shape location is used multiple times across the spline.
The second scratch pad below goes under curl noise and scale mesh. It dictates the movement of the fish along the spline
It samples the closest location on the spline relative to the fish, calculates a speed and direction, and rotates things aswell. Once that's done it sets the Trainsient variable Physics Force, which overwrites the particles movements.
However, the speed is dependent on the length of the spline...and adding a single variable where I did to make it faster does not account for turning areas at the moment.