- Home /
Is it safe to animate collision boxes?
Is it safe to animate collision boxes when they are only used to detect overlap?
The collision boxes are being used for overlap detection with damage/hurt boxes.
The boxes are not being used for physics calculations.
Thanks for the info!
Answer by Cornelis-de-Jager · Jan 09, 2019 at 12:35 AM
When I use colliders on character animations I don't "animate" them. I will animate the model and then add colliders to the bones of the models. That in tern moves the colliders and gives the illution on them being animated. But in reality its simply moving them within world space which is 100% safe.
Hope this is what you meant and hope this helps.
The Character is a 2d character. Im just asking if its safe to move boxes and animate them via the animator, or if there are any downsides to doing this.
Answer by Kudorado · Jan 09, 2019 at 05:11 AM
Cause the PhysicsOverlap
just like a simple Raycast
function, it's just happened at the frame you call.
PhysicsOverlap
pretty accurate, i recommend using with moving object not though Rigidbody
, Animated
object.
Answer by michi_b · Jan 09, 2019 at 07:06 AM
Of course, it would also be safe to animate kinematic rigidbodies that trigger collisions, if you know about the implications and how to deal with them.
Anyway, if you are just animating a triggering collider, the only thing you should think about is whether the accuracy of the collision detection is allowed to be frame rate dependent.
If so, keep the usual time driving your animation. Otherwise, switch it to physics time (so it updates in sync with physics calculations and movement). But then you might notice jittering in the animation, which is caused by the physics update loop not beeing perfectly in sync with the normal (frame rate dependent) update loop. If so, you can also attach a kinematic rigidbody (just to keep track of speed) to the box collider and experiment with its interpolation mode to get rid of the jittering. The result will not be as perfect as when using normal aniamtion update time though. Interpolation will induce a small lag and extrapolation will induce small jumps in the animation when it changes direction abruptly.