I’m trying to create a melee hit detection system that can detect a weapon passing through very thin parts. What I have thought of doing is creating a part between the position in the last frame and the current position of the weapon, but I just can not figure it out.
It’s kind of difficult to explain, but what I basically want is something that would look like roblox’s trails, but it would be made of a part.
So for example, the pink part is the weapon in the previous frame and the green part is the weapon in the current frame:
My problem is that I do not know how to fit the part in between the two attachments. I have tried many things with a cube’s cframe, adding wedges to make the part fit, etc. but nothing has worked. Any help is appreciated, thank you!
Update: I was able to get a good result visually with a rigged plane by positioning its bone cframes to the attachment cframes, but this does not work, unfortunately, since it seems that roblox does not update the plane’s hitbox with the deformation of the bones.
Assuming I’m getting this right, might I recommend calculating the distance between the two points and correspondingly updating the size and position of the part? You would need to update this every time the part has changed.
Alternatively, if I’m correct about this situation, it may be easier to use attachments and a trail effect and/or beam to recreate this effect in a cost efficient method.
Thank you for the reply. Just sizing and positioning a part in between the two points is the first thing I thought of, but the problem with that is that the shape in between the two lines is not a perfect square.
And I wish I could just use a trail, but I would need a way to detect what parts the trail is touching, which is not possible.
i was actually looking at your post earlier yesterday lol. it is really hard to word such a specific thing.
i still havent found a solution and have kind of given up, so im just using raycasts now
Correct. Hitbox of a skinned mesh never changes. Deformation from bones is visual only, done entirely on the GPU. The physics engine uses a different mesh entirely, or more accurately, a bunch of convex parts that–all together–approximate the visual mesh in its un-deformed original state.
What you can do though, is fit 2 thin wedge parts to the vertices, to triangulate it. A single part can’t twist, so it’s not going to be a very good approximation if the two positions of the weapon are nowhere close to being parallel. Another option would be to break up the “sheet” in between the weapons into thin strips of thin rectangular slats, like the planks of a rope bridge, so that you get something that conforms more closely to a twisting path. You can just put some number of sample points on the line segments between the previous and current positions of each end of the sword, evenly spaced, and line up parts connecting them. The parts can overlap, it doesn’t need to be pretty. Because of client-server latency, melee interactions are never going to feel anything close to precise, so your collision detection doesn’t need to be either.