Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to add a delay/trail to Collision?


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.

alt text

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


Product Version: UE 4.16
how.png (57.3 kB)
more ▼

asked Feb 22 '18 at 08:45 AM in Blueprint Scripting

avatar image

26 1 5 3

avatar image Exonfluxx Feb 22 '18 at 02:11 PM

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

avatar image Delos-X Feb 23 '18 at 06:05 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first


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.

alt text

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.

alt text

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.

alt text

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.

alt text

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.


trailb.png (90.4 kB)
traild.png (115.2 kB)
traile.png (59.0 kB)
trailf2.png (406.2 kB)
more ▼

answered Feb 23 '18 at 07:27 AM

avatar image

26 1 5 3

avatar image Arceyo Feb 23 '18 at 04:48 PM

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.

avatar image Delos-X Feb 23 '18 at 06:16 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question