Hi!
I have animation that moves the object in space. Such a simple case, the character (box collider, isKinematic = true), runs forward (animation changes its position.) On his way there is an enemy (box collider, isKinematic = true), it is necessary so that the character could not run through it. In this case, it is necessary that when a character approached the enemy close, it does not move (not to go through), but the animation did not stop.
I’m doing a check in LateUpdate the intersection Bounds of Colliders and RigidBody SweepTest, if there is hit or intersection, then make _animator.applyRootMotion = false. This stops a character on the spot, while playing the animation. But, if the animation contains such bounce back after a run, then I have to turn back mode _animator.applyRootMotion for resume movement of the character.
Animation looks like - a fighter running away, does a kick, and runs back.
In my case it would be something like:
- Fighter running
- Check SweepTest Hit or Bounds Intersection // during the animation soldier approached the enemy
- applyRootMotion = false, still run frame or frame kick // animation is played, and the character is in place before the enemy
- Now in animation fighter should run back ago, but since it is one big animation, it is not clear how to turn when you need applyRootMotion = true;
That is, it is necessary that all forward displacement of the object animation stopped transforms shift before enemy (applyRootMotion = false), but did not stop the animation. And all the backward movement of the object happening with animation (applyRootMotion = true).
Or what that is another solution?
I use it for fighting game.
May be easier and better to do manual control (via script - transform.Translate(…)) a fighter and not through animation?
Thanks!
