// Update is called once per frame void FixedUpdate() { float angle; Vector3 pos; if (Globabl_stats.is_battle_launched == false) { return; } if (local_values.cur_health <= 0) { Destroy(this.gameObject); } closest_enemy = find_closest_enemy(); if (closest_enemy == null) { return; } pos = closest_enemy.transform.position - transform.position; angle = anglescript.calc_angle(closest_enemy); transform.eulerAngles = new Vector3(transform.eulerAngles.x, angle, transform.eulerAngles.z); collision_script.check_collisions(); enemy_values = closest_enemy.GetComponent <Obj_values>(); if (enemy_col == false && projectil_col == false) { move_script.movements(); } else { move_script.attack(enemy_values, local_values); } }
public void attack(Obj_values enemy_values, Obj_values local_values) { t0 = Time.time; if (t0 >= mother_script.t1 + 0.5) { anim_script.anim.Play("Armature|Hit"); mother_script.t1 = t0; enemy_values.cur_health -= local_values.attack; Debug.Log(this.tag); } }