Question by
zoystudios · Sep 05, 2019 at 07:21 AM ·
c#animationwalking
How to Stop Enemy Walking Animation When It Stop Movement
{ public Transform Player; private Animator anim; private Rigidbody rb; int MoveSpeed = 4; int MaxDist = 10; int MinDist = 5;
void Start()
{
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody>();
}
void Update()
{
transform.LookAt(Player);
if (Vector3.Distance(transform.position, Player.position) >= MinDist)
{
transform.position += transform.forward * MoveSpeed * Time.deltaTime;
if (Vector3.Distance(transform.position, Player.position) <= MaxDist)
{
}
}
}
public void Walk (bool Move)
{
anim.SetBool("Movement", Move);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612211716im_/https://answers.unity.com/themes/thub/images/avi.jpg)