Get my addon Magic Trails if you want to have cool trails like these in your scene with very few clicks:
It is a nice method but it bugged me that the process of creating the trail is pretty tedious and most importantly, every time, you update your base animation, you have to bake the animation of all the trail points all over again. Since i have been messing with the Serpens Visual Scripting Addon lately, i was wondering, if i could improve on that and make it realtime so that you can swipe it around in the viewport and it still works.
I took the basic principle of taking a plane that would later be the mesh for the trail and adding an armature to control the vertices of the plane.
Here i first have all 8 vertices of the plane be controlled by 8 empties with the hook modifier and the empties copy the location of 4 bones (tip and root) so that my trail now has 4 segments.
Now here is where the fun begins: in principle the bones have a hierarchy so that each bone follows the one before itself but with an offset. Obviously, a time offset would not be possible without baking so i had to find a way to get the same effect with a location, rotation and scale offset.
The solution: lerping
Lerping is a function that determines a midpoint of two values with another parameter as a lerp factor.
This is what the mathematical function looks like: d = a * (1 - c) + b * c
The result d is a value between a and b with c being a parameter to control how much d is leaning towards a or b.
c = 0.5 will return the average between a and b
c = 0 will return a
c = 1 will return b
Why is this useful? We can use this function to make one object follow another object. To do this, we lerp the transforms of our “following” object X with the transforms of our “leader” object Y and apply them to X. When we only look at the location and use lerp factor c = 0.5, we will see that the location of X is now half way between its original location and the location of Y. But now, the location of X has changed and again, using the lerp function, X will move half the distance between itself and the leader Y. To use this function, we will use drivers (scary, i know).
This is what the driver for the X component of the location would look like:
Lets move on to some real examples:
Here we have the basic setup. X is at the origin and Y is 10m away from the origin (and X). Now when we lerp the transforms of X with a lerp factor of 0.5, it will move 5m towards Y because
0*(1-0.5) + 10 *0.5 = 5 (we will only look a one axis for now).
Repeating this process, X will next move to 7.5m (2.5m towards Y from its last position) because
5*(1-0.5) + 10*0.5 = 7.5
We can do this for all axis and for rotation and scale respectively. We now have an object that follows another object while keeping some distance.
We can repeat this process if we take an object Z that follows X around. We will get a nice swarm of objects that follow a leader, each object dragging behind more and more. We can add as many objects to this chain as we want but instead of using cubes, we can also use bones for that. The plane that is being influenced by the bones will then be part of the almost-simulation, that we just created.
And there we have it. Now we only need to slap a material on the plane and our trail is ready to go.
There is only a tiny problem: how fast and when does blender update its drivers? During an animation, it will do that every frame, which is good because a reliable and constant refresh rate is what we want for our trail, the viewport works too (i dont really know how blender updates its drivers there, its a bit weird). What sucks is that the lerping does not seem to work, when we render an animation. Drivers get updated of course but not our lerping objects for some reason.
So to fix that, we DO have to bake the animation for our controller bones, but only before rendering and we still have our realtime viewport animation.
If you are interested, you can get an addon that i made using Serpens, that will add such a trail with very few clicks to your scene, ready to animate.
Get it here: https://gumroad.com/l/magic_trails