// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.J)) { playerAnimations.Defend(true); shield.ActivateShield(true); } if (Input.GetKeyUp(KeyCode.J)) { playerAnimations.UnfreezeAnimation(); playerAnimations.Defend(false); shield.ActivateShield(false); } if (Input.GetKeyDown(KeyCode.K)) { if (Random.Range(0, 2) > 0) { playerAnimations.Attack1(); soundFX.Attack1(); } else { playerAnimations.Attack2(); soundFX.Attack1(); } } }
void AttackPlayer() { navagent.velocity = Vector3.zero; navagent.isStopped = true; EnemyAnimations.Walk(false); AttackTimer += Time.deltaTime; if (AttackTimer > waitbeforeAttckTime) { if (Random.Range(0, 2) > 0) { EnemyAnimations.Attack1(); soundFX.Attack1(); } else { EnemyAnimations.Attack2(); soundFX.Attack2(); } AttackTimer = 0f; } if (Vector3.Distance(Playertarget.position, transform.position) <= attackDistance + chasePlayerafterAttackdistance) { navagent.isStopped = false; enemystate = EnemyState.CHASE; } }