fixed checkpoints and AI
This commit is contained in:
@@ -36,8 +36,17 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
GameObject player = players[i];
|
||||
|
||||
if (playersFinished.Contains(player.name) || playersFinished.Contains(player.name + " (player)"))
|
||||
continue;
|
||||
try
|
||||
{
|
||||
if (playersFinished.Contains(player.name) || playersFinished.Contains(player.name + " (player)"))
|
||||
continue;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool isAI = true;
|
||||
if (player.GetComponent<PlayerController>().enabled)
|
||||
|
||||
@@ -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