private void FixedUpdate() { cooldown -= Time.fixedDeltaTime; if (cooldown > 0.0f) { return; } if (tank.IsEmpty()) { return; } if (!GameController.Instance.IsGameActive()) { return; } if ((Input.GetMouseButton(0) || Input.GetKey(KeyCode.Space)) && body.velocity.y <= maxSpeed) { body.AddForce(new Vector2(0.0f, upwardForce)); tank.Burn(upwardForce * fuelConsumptionPerNewton); } var height = transform.position.y; if (height > shutdownHeight) { cooldown = shutdownDuration; } }
private void FixedUpdate() { if (!GameController.Instance.IsGameActive()) { return; } var speed = body.velocity.x; var force = Mathf.Min(relativeForce * (targetSpeed - speed), maxForce); var delta = Time.fixedDeltaTime; if (!tank.IsEmpty()) { body.AddForce(new Vector2(force * delta, 0.0f)); tank.Burn(fuelConsumptionPerNewton * force * delta); } }