// Update is called once per frame void Update() { if (moving) { transform.position += dir * vel * Time.deltaTime; } else { if (wallCollision) { transform.position = new Vector3(transform.position.x, transform.position.y + 0.1f, transform.position.z); } timeGoneBy += Time.deltaTime; if (timeGoneBy >= 1) { if (wallHit == 1) { wattBarManager.LoseWatt(2f); lostWattage += 10f; } else if (wallHit == 2) { wattBarManager.LoseWatt(5f); lostWattage += 15; } else if (wallHit == 3) { wattBarManager.LoseWatt(7f); lostWattage -= 20f; } timeGoneBy = 0; } } }