private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Obstacle"))
        {
            // Stop everything
            isRunning = false;
            vehicleRigidbody.velocity = Vector3.zero;

            // Notify the render twin
            vehicleRenderController.OnPlayerDeath();
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (gameManager == null || vehiclePhysicsController == null || vehicleRenderController == null)
        {
            return;
        }

        // Don't burn fuel if physics isn't running
        if (false == vehiclePhysicsController.IsRunning())
        {
            return;
        }

        float currentFuel = gameManager.GetCurrentFuel() - Time.deltaTime * fuelBurnSpeed;

        gameManager.SetCurrentFuel(currentFuel);

        // TODO: Should play a warning sound (fast beep?) shortly before we run out (maybe flash the UI display?)
        if (currentFuel < 0)
        {
            vehicleRenderController.OnPlayerDeath();
        }
    }