Advanced sword collision detection problem

I’m developing a melee combat system with reallistic collision. I’ve hit a roadblock when looking for a decent method of anticipating a hit in order to stop the sword and avoid penetration.

I know there are many different ways to interpolate sword location between frames and find all collisions. The problem is that they can only detect a hit after the sword has already passed through an object. Even if you correct it instantly the penetration will still be visible for one frame. I know some people use precalculated arcs. It’s sadly impossible in my case. I have only a few ideas on how to fix it.

  1. Extrapolation. It kinda works. There are several methods, all have flaws. The ending of animation is especially problematic as the sword speed is quickly reduced. Does anyone know any way to accurately extrapolate such movements?

  2. Correct sword position before the frame renders. Is this even possible? Could you update the animation, look for collision, correct it and only then render? Does the engine even allow things like this?

I would be really greatful if anyone could share some thoughts

penetration will still be visible for one frame

is that really that bad? 1 frame is what 1/30-1/120th of a second. i doubt that will be that noticeable or break the immersion, even more so you immediately begin a retraction anim.

as for your question i dont have an answer but its custom code territory (c++)

Well, if I can see that frame so will the players. Custom C++ is not a problem, I appreciate any solutions

Ok, I have found a solution. I don’t fully understant how to apply it to my system but I’ve done some testing and it appears to be exactly what I’m looking for.

Post Process Animation Blueprint
It’s mostly used for IK and dangling bones but in the context of collision it can correct positions of bones after the basic animation blueprint does its thing.

Now I can detect collision with interpolation and use post process animation to move the sword back in case of penetration