fixed checkpoints and AI
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user