// Update is called once per frame void FixedUpdate() { if (this.anim.GetCurrentAnimatorStateInfo(0).IsName("WrongSlap")) { timer += Time.deltaTime; AIMove.SetMoveDirection(Vector3.zero); if (timer >= this.anim.GetCurrentAnimatorStateInfo(0).length) { AIMove.SetMoveDirection(new Vector3(Random.Range(-1, 2) * AIMove.Speed, 0, Random.Range(-1, 2) * AIMove.Speed)); anim.SetBool("IsSlapped", false); timer = 0f; } } }
// Update is called once per frame void Update() { _timer += Time.deltaTime; if (_timer >= WaitTime) { _timer = 0f; if (_currentObjectAmount < maxObjectAmount) { anim.Play("Throw", 0, 0.5f); spawnTrash(); AIMove.SetMoveDirection(Vector3.zero); if (!this.anim.GetCurrentAnimatorStateInfo(0).IsName("Walking")) { AIMove.SetMoveDirection(new Vector3(Random.Range(-1, 2) * AIMove.Speed, 0, Random.Range(-1, 2) * AIMove.Speed)); } } } }