void Attackplayer() { navAgent.velocity = Vector3.zero; navAgent.isStopped = true; enemy_anim.Walk(false); attack_timer += Time.deltaTime; if (attack_timer > wait_before_attack_time) { if (Random.Range(0, 2) > 0) { enemy_anim.Attack1(); soundFX.Attack_1(); } else { enemy_anim.Attack2(); soundFX.Attack_2(); } attack_timer = 0f; }//if we can attack if (Vector3.Distance(transform.position, playerTarget.position) > attack_distance + chase_player_after_attack_distance) { navAgent.isStopped = false; enemy_State = EnemyState.CHASE; } }
// Update is called once per frame void Update() { // defend when press J if (Input.GetKeyDown(KeyCode.J)) { playerAnimation.Defend(true); shield.ActiveShield(true); } // release when J unpressed if (Input.GetKeyUp(KeyCode.J)) { playerAnimation.UNFreezeAnimation(); playerAnimation.Defend(false); shield.ActiveShield(false); } // Attack when press K if (Input.GetKeyDown(KeyCode.K)) { if (Random.Range(0, 2) > 0) { playerAnimation.Attack1(); soundFX.Attack_1(); } else { playerAnimation.Attack2(); soundFX.Attack_2(); } } }
void Update() { if (Input.GetKeyDown(KeyCode.J)) { playerAnimation.Defend(true); shield.ActivateShield(true); } if (Input.GetKeyUp(KeyCode.J)) { playerAnimation.UnFreezeAnimation(); playerAnimation.Defend(false); shield.ActivateShield(false); } if (Input.GetKeyDown(KeyCode.K)) { if (Random.Range(0, 2) > 0) { playerAnimation.Attack1(); soundFX.Attack_1(); } else { playerAnimation.Attack2(); soundFX.Attack_2(); } } }//update