I FINALLY GOT IT WORKING!
So, this was a little annoying. I tried a lot to get it working but finally found the way.
I used four things to create the trail: A separate blueprint actor, a struct, an array and a procedural mesh. I had to create all of this in a seperate actor because ‘get socket location’ uses world location, so having that in the saber itself made it really weird and off.
First, I created the new actor (I’ll call it ‘Trail Actor’) and placed it in the level - setting it to 0,0,0 in the world location. That means all relative locations match up to the world locations. In this new actor, I added a new ‘Procedural Mesh’ component and set that to be the root.
Within the event graph of this Trail Actor I first created a variable reference to the lightsaber blade, making sure to set it to public (click on the closed eye). Within the level itself, I selected on the Trail Actor I placed in the level and was able to select an actor in the details panel to act as this new variable reference.
Within the content browser I created a new blueprint struct (calling it saberstruct) - inside that struct I added two Vector locations, Bone001 and Bone002 (I am using Bones in the blade of the saber to make the animtrail work) - these are the base (001) and tip (002) of the blade.
Back into the event graph of the Trail Actor I took the saber ref variable and did ‘Get Socket Location’ of BoneA and BoneB, plugging them into the ‘Make SaberStruct’ node. From that node, I promoted this struct into an Array - I’m calling this StructArray. Now, I needed to to add this struct to the array once during the ‘Event BeginPlay’ event for when I create the mesh, and again on the ‘Event Tick’ event for when I update it. Because of my habits, I have these coming off of Custom Events which are hooked up to the BeginPlay and Tick event respectively.
Now I need to make sure this StructArray doesn’t get too large, and to only hold the most recent structs and delete old ones. So, I used a branch node with the trigger of this branch being if the length of the array is above a certain amount. In my case, I wanted 11 entries of the Array, so if the Array equalled 11, I’d delete index 0 in the array. I had this hooked up to the end of the Tick customevent.
Now for the fun part! I needed to get each index of the StructArray, break the struct for each one, and add that into a ‘Make Array’ Node which is used for the ‘Vertices’ part in the Procedural mesh. The Green arrays are for the triangles of the mesh - If you’re wanting to create a trail like this, I found a little trick. Starting from index 0, you go +1, +1, +1, +1, -1, -1 and repeat until the end of the array is your last Yellow Array point -2 in the green array. This’ll create squares properly for the trail, making the actual trail itself.
From there, I do a ‘create mesh section’ in the beginplay custom event, and in the Tick custom event, I do a ‘Update Mesh Section’, plugging the two new giant arrays into the Verticies and Triangles respectively. Make sure ‘Create Collision’ is checked on the create mesh section and voila! We have a trail with collision. From there, I went on to hook this up to my bullets and made it so they reflected off this new mesh! Hooray!
Here’s a GIF of the result, note that the mesh is only visible on one side since I haven’t set any material (I’m going to make it invisible and use my own Animtrail, which looks prettier), but it works! I just need to get better at it.