- Home /
How to bypass an AnimationClip precise curve when colliding ?
Hello,
Let's say you have an animated character that perform an animationClip : he leaps forward, then return back. How can we constraint that animation with its colliders ?
For example, during his forward leap he finds himself to enter the enemy BoxCollider, therefore he should be blocked instead of leaping through, as long as collision is detected. When the animated Clip's position exits that collider, our character should not be blocked anymore, and animate normally, coming back to its initial position.
This is a very common scenario, unfortunately. Some movements are too complex to be hard coded, and this is where a predefined animation is required.
I guess there is no easy way to do this. Would the trick be to bypass the X position curve when hit is detected ? How is it doable at runtime without clumsily overriding the animated position with an Update() translation/setPosition ?
Thank you in advance :)
Answer by n0mad · Feb 18, 2011 at 01:17 PM
Silly me ... I forgot the LateUpdate() function ...
LateUpdate() is performed after animations, so we can put any check/final constraints in here. Awesome.
Your answer
![](https://koobas.hobune.stream/wayback/20220613105009im_/https://answers.unity.com/themes/thub/images/avi.jpg)