// Update is called once per frame void Update() { if (startTimer > 0) { startTimer -= Time.deltaTime; } else if (startTimer <= 0) { ship.dealDamage(damageOverTime); startTimer = timer; } if (hasPlayer) { if (Input.GetKey(KeyCode.C)) { repairTime -= repairSpeed; UpdateBar(); } } if (repairTime <= 0) { Destroy(gameObject); } }
private void Update() { if (!chase) { if (startTimer > 0) { startTimer -= Time.deltaTime; } else if (startTimer <= 0) { Instantiate(damageToSpawn, transform.position, Quaternion.identity); ship.dealDamage(shipDamage); startTimer = timer; } } else { transform.right = transform.position - player.transform.position; transform.position = Vector2.MoveTowards(transform.position, player.transform.position, speed * Time.deltaTime); } }