fix errors

This commit is contained in:
magn9775
2024-04-26 18:31:17 +02:00
parent 2edf1925ca
commit 61d1958308
3 changed files with 153 additions and 17 deletions

View File

@@ -17,8 +17,6 @@ public class GameController :MonoBehaviour
public static bool RaceIsStarted { get { return true; } }
public static bool RaceIsEnded { get { return false; } }
public TextMeshPro speedometer;
public List<GameObject> cars;
int CurrentCarIndex = 0;
@@ -29,14 +27,7 @@ public class GameController :MonoBehaviour
{
finished=gameObject.GetComponent<GameManager>().playersFinished;
if (speedometer == null)
{
speedometer = new TextMeshPro();
}
if (carRB == null)
{
carRB = GetComponent<Rigidbody>();
}
}
public void Update ()
@@ -47,9 +38,7 @@ public class GameController :MonoBehaviour
NextCar ();
}
carVel = (math.abs(carRB.velocity.x) + math.abs(carRB.velocity.y) + math.abs(carRB.velocity.z))*5;
//print(carVel);
speedometer.SetText(carVel.ToString());
}

View File

@@ -26,6 +26,8 @@ public class GameManager : MonoBehaviour
public GameObject nextCarbtn;
float DNFTimer = 0;
private bool hasCountedDown = false;
private Rigidbody carRB;
void Start()
{
AudioSource backgroundMusic = GameObject.Find("Car Data").GetComponent<AudioSource>();
@@ -96,9 +98,8 @@ public class GameManager : MonoBehaviour
else
{
int checkpointsCollected = player.GetComponent<PlayerController>().checkpointsCollected;
carRB = player.GetComponent<RigidBody>();
carVel = (math.abs(carRB.velocity.x) + math.abs(carRB.velocity.y) + math.abs(carRB.velocity.z))*5;
carRB = player.GetComponent<Rigidbody>();
var carVel = (Mathf.Abs(carRB.velocity.x) + Mathf.Abs(carRB.velocity.y) + Mathf.Abs(carRB.velocity.z))*5;
speedometer.SetText(carVel.ToString());
if (checkpointsCollected == checkpoints.Count())