// runs on every frame void Update() { b = Spawn.GetCurrentPlayer().GetComponent <Build>(); inventory = Spawn.GetCurrentPlayer().GetComponent <Inventory>(); // if Builder currently is holding a building, set buildDelay to now if (b.HasBuilding()) { buildDelay = DateTime.Now; } // if Now - buildDelay exceeds the cooldown, we can enter the 'firing' code if ((DateTime.Now - buildDelay) > delayCoolDown || buildDelay == null) { // if user has clicked main attack button, and the atackCooldown is passed if (Input.GetButtonDown("Fire1") && (lastAttack == null || (DateTime.Now - lastAttack) >= attackCooldown)) { // null check animator, and if so, set off the Attack animation (swing the tool) if (animator) { animator.SetTrigger("Attack"); } lastAttack = DateTime.Now; } } }