game engine – Unity3d Prevent collision missing during fast animations
In Unity 3D, I have a character with a swing animation. I want to detect the exact movment of sword collision so I can stop the swing motion and return to Idle. I am trying to achive this using several ways.
-
Method 1 – I have a collider & rigidbody combination for the sword where I can register onCollision event. ( This is the most accuracte but It misses the collision event most of the time, since anmations are somwhat 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 collide with the blade I register it has hit ( This all has the same problem of method one, but somewhat sucessfull – raycast if done in FixedUpdate function)
-
Method 3 – I have set of point aligned with the enemy blade and Players blade, So In every FixedUpdate event I calculate the distance between each points, If a distance threashold is reached, I take it as a hit. ( This is the most sucessful method but this register so many unrealistic hits)
For all 3 methods I have set proper collision detection for rigidbodies and fix update time is minimized
So, My question is there a better way to register meele weapon collisions at the excat collision time
Read more here: Source link