- Home /
Other
Walk Animation restarting over and over
I downloaded an animation from Mixamo (DID NOT check In Place), but my character starts walking, then it resets and walks in the same place over and over (Well it goes a few feet then resets). I also, do not have Loop Pose selected in Unity. How do I get continually movement from my walk animation on my character without the resetting of the animation???
Answer by tamarar357_unity · Nov 26, 2019 at 04:53 PM
I also tried setting the checkbox to "Apply Root Motion" (So I assume my character animation is set to Humanoid? I will have to check this...
But I set it to "Apply Root Motion" and it still didn't work...
When you import the animation, are all of those root motion/rotation boxes checked?
Here is what I have, now the enemy walks towards the player, but I need it to stop when it reaches the player, how do I do that part?
public class ScareCrowController : $$anonymous$$onoBehaviour { public Transform player; static Animator anim;
public void Start()
{
anim = GetComponent<Animator>();
}
private void Update()
{
if (Vector3.Distance(player.position, this.transform.position) < 10)
{
Vector3 direction = player.position - this.transform.position;
this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
Quaternion.LookRotation(direction), 0.1f);
Vector3 newPosition = transform.position;
newPosition.z -= anim.GetFloat("RunSpeed") * Time.deltaTime;
anim.SetBool("IsWalking", true);
transform.position = newPosition;
}
}
}
Never $$anonymous$$d figured it out something with distance.magnitude I had to change to get the character to stop.
Answer by hanzla007 · Nov 26, 2019 at 11:36 AM
My friend, You need to make the animation humanoid first and when both the character model and the animation are set to "Humanoid" you will be able to checkbox the "Apply Root Motion" box in the Animator component of your character... I hope you get it.