void FixedUpdate() { if (levelManager.CurrentLevelMode == LevelManager.LevelMode.PLAY && !crashed && !GotToGoal) { var allTowers = FindObjectsOfType <Tower>(); float totalTurn = 0; foreach (var tower in allTowers) { if (tower.IsCarAffected(transform.position)) { totalTurn += tower.TurnEffect; transform.Rotate(Vector3.up, tower.TurnEffect * Time.deltaTime, Space.World); } } var newPosition = transform.position + Speed * Time.deltaTime * transform.forward; transform.position = newPosition; // Check if car is above ground, "crash" otherwise if (!Physics.Raycast( transform.position + Vector3.up * 0.5f, Vector3.down, 2, LayerMask.GetMask("Ground"), QueryTriggerInteraction.Ignore )) { Crash(CrashType.STOP); } carModelBehavior.StartSmoke(); if (totalTurn > Mathf.Epsilon) { carModelBehavior.TurnRight(); } else if (totalTurn < -Mathf.Epsilon) { carModelBehavior.TurnLeft(); } else { carModelBehavior.TurnStraight(); } } else { carModelBehavior.StopSmoke(); carModelBehavior.TurnStraight(); } }