// Update is called once per frame void Update() { switch (CurrentState) { case mortorState.idle: break; case mortorState.shoot: if (Time.time > nextTimeFire) { if (target_ != null) { Vector3 vo = Calculatevelocity(target_.transform.position, firePoint.position, speed); shoot(vo); nextTimeFire = Time.time + gameObject.GetComponent <towerInf>().fireRate; } else { CurrentState = mortorState.idle; } } break; } }
public void stopShoot() { CurrentState = mortorState.idle; target_ = null; }
public void shoot(GameObject targetGameObject) { CurrentState = mortorState.shoot; target_ = targetGameObject; }