private void animate() { animator.SetFloat("speed", Mathf.Abs(horizontalMovement)); animator.SetBool("isJumping", !isGrounded); if (Mathf.Abs(horizontalMovement) > 0.01 && isGrounded) { playerAudio.setRunning(true); } else { playerAudio.setRunning(false); } }
private void Update() { if (target != null) { float distance = Vector3.Distance(target.transform.position, transform.position); if (distance <= lookRadius) { isIdle = false; if (target.position.x - transform.position.x > 0) { facingRight = 0; } else { facingRight = 1; } isChasing = Mathf.Abs(distance) > minDistance ? true : false; if (attackController.getAttackState() == false) { animator.SetBool("isChasing", isChasing); attackController.setAttack(!isChasing); } animator.SetBool("isTargetReachable", true); enemyAudio.setRunning(isChasing); } else { isIdle = true; isChasing = false; animator.SetBool("isChasing", false); animator.SetBool("isTargetReachable", false); enemyAudio.setRunning(false); } } else { isIdle = true; isChasing = false; animator.SetBool("isChasing", false); animator.SetBool("isTargetDead", true); attackController.setAttack(false); enemyAudio.setRunning(false); } }