fixed checkpoints and AI

This commit is contained in:
2024-04-26 12:25:28 +02:00
parent d49e58e008
commit 49b4414155
19 changed files with 1395 additions and 552 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class PlayerController : MonoBehaviour
@@ -125,10 +126,21 @@ public class PlayerController : MonoBehaviour
private void Update() {
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
float checkpintDistance = distanceToCheckpoint(currentCheckpoint);
if (checkpintDistance < 0.1f)
{
checkpointsCollected += 1;
currentCheckpoint.GetComponent<Checkpoint>().isVisible = false;
Transform nextCheckpoint;
if (checkpointsCollected <= checkpoints.Count() - 1)
nextCheckpoint = checkpoints[checkpointsCollected].transform;
else
nextCheckpoint = checkpoints[0].transform;
nextCheckpoint.GetComponent<Checkpoint>().isVisible = true;
}
}