private void FixedUpdate() { var dir = rb.velocity.normalized; var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); if (!GameManager.Instance.isRunning) { return; } Vector2 gasVector = gas.ReadValue <Vector2>(); if (gasVector != Vector2.zero) { if (fuelSystem.fuelEmpty) { gasVector.y = 0; gasVector.x *= 0.1f; } rb.AddForce(dir * gasVector.y * accAmount); rb.AddForce(new Vector2(dir.y, -dir.x) * gasVector.x * accAmount * 4f); fuelSystem.DepleteFuel((Mathf.Abs(gasVector.y) * fuelCostGas + Mathf.Abs(gasVector.x) * fuelCostTurn) * Time.deltaTime); if (gas.ReadValue <Vector2>().y > 0) { audioManager.playSound(accLoopSound); } else if (gas.ReadValue <Vector2>().y < 0) { audioManager.playSound(breakLoopSound); } } if (gasVector.y > 0) { flameSprite.enabled = true; } else { flameSprite.enabled = false; } if (gas.ReadValue <Vector2>().y == 0) { StopEngineSounds(); } }