Unity3d Prevent collision missing during fast animations
In Unity 3D, I have a character with a swing animation. I want to detect the exact movement of sword collision so I can stop the swing motion and return to Idle. I am trying to achieve this using several ways.
- Method 1 – I have a collider & rigid body combination for the sword where I can register onCollision event. ( This is the most accurate but It misses the collision event most of the time since animations are somewhat fast ( even if slows down the animation to 0.3, there are random misses)
- Method 2 – I am doing raycasting from sword hilt to the end of the blade, If something collides with the blade I register it has hit ( This all has the same problem of method one, but somewhat successful – raycast if done in FixedUpdate function)
- Method 3 – I have a set of points aligned with the enemy blade and Players’ blade, So In every FixedUpdate event, I calculate the distance between each point, If a distance threshold is reached, I take it as a hit. ( This is the most successful method but this register so many unrealistic hits)
For all 3 methods, I have set proper collision detection for rigid bodies, and fix update time is minimized
So, My question is there a better way to handle collisions during fast animations?
Read more here: Source link