- Home /
2D: Animate physics doesn't work with Animator?
I am using Unity 2D. I have my enemy object with a script to have him follow the player (and flip to face him). I created a Hurt animation for when they enemy is punched. When I enable the animator, the punch animation triggers as it should. However, the enemy no longer follows the player! I have animate physics checked. When I disable the Animator the enemy follows the player as it should. Do I have to choose one or the other?
Here is my follow code:
void FixedUpdate () {
if (Vector3.Distance (target.position, myTransform.position) > maxDistance) {
if (target.position.x < myTransform.position.x) {
myTransform.position -= myTransform.right * moveSpeed * Time.deltaTime;
if (facingRight)
Flip ();
}
else if (target.position.x > myTransform.position.x) {
myTransform.position += myTransform.right * moveSpeed * Time.deltaTime;
if (!facingRight)
Flip ();
}
}
anim.SetBool ("EnemyHurt", EnemyHurt);
}
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Is there a way how to use both Animate Physics and Unscaled Time update modes in animator ? 0 Answers
How to animate collider along with object for 2D game? 0 Answers
How can I use Animate Physics in a project? 2 Answers
Using a sprite sheet in a 3d enviroment? 0 Answers