How to add a delay/trail to Collision?

Heya,

So, I’m making a VR thing for fun - involving swords (well, lightsabers). I’ve added in projectile reflection but I’d like to make it easier to accomplish, since the collision for the saber itself is rather small. Is it possible to add a trail to the collision, much like an Animtrail (which I have setup and on already, if I could use that it’d be great)? The rough image I made below should hopefully give an idea of what I’d like to create.

Hope this conveys what I’d like to achieve - as trying to deflect a high speed bullet is rather difficult at the moment.

Thanks!

That is a tough one.

Could use very bright light.

could use particle EFX that emit light

could have it spawn non collision versions of the blade mesh for a very short time while moving. (Which I would task as a EFX)

Hope I gave ya some Idea’s

I don’t want to create a trail - I have that already in my Animtrail. What I want to achieve is an Animtrail (or something similar to it) that has collision.

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.

Impressive stuff. Little late now, but I might’ve suggested just making the projectile collision bigger. Still, what you’ve done here is super cool. Nice work.

Thanks! I thought of that, but if I did it with the capsule collision I had in it now, it’d skew the bounces in the projectile movement a lot and make it harder to aim. With this, I’ve been getting the hang of it and can now aim kinda consistently.

Downside to this method is that I’m using up a lot of performance with this - I’m starting to lag in this scene (though, my PC is the min spec for the vive). I can probably fix this by using every 3rd index in the array instead of all of them, or alternatively I could use another much less performance heavy idea - I could simply take the forward vector of the bones, multiply that by -1 and use those two vectors multiplied by the velocity combined with the normal vector locations for the bones for a much more efficient (but less accurate, since it would just result in a box that’s extended from your blade and isn’t too much like the animtrail.