Game Manager WIP

This commit is contained in:
2024-04-24 08:53:46 +02:00
parent ccd2ea506b
commit 7b313fe2d4
14 changed files with 373 additions and 473 deletions

View File

@@ -121,21 +121,27 @@ public class PlayerController : MonoBehaviour
}
private void Update() {
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
float checkpintDistance = distanceToCheckpoint(currentCheckpoint);
if (checkpintDistance < 0.1f)
{
checkpointsCollected += 1;
}
}
private void OnCollisionEnter(Collision other) {
if (other.gameObject.tag == "Wall")
{
// audio.Play();
}
}
private void OnTriggerEnter(Collider other) {
print(checkpointsCollected);
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
if (other.gameObject == currentCheckpoint)
{
checkpointsCollected += 1;
print(checkpointsCollected);
}
float distanceToCheckpoint(Transform checkpoint)
{
var closestPoint = checkpoint.GetComponent<Collider>().ClosestPointOnBounds(transform.position);
var distanceToCheckpoint = Vector3.Distance(transform.position, closestPoint);
return distanceToCheckpoint;
}
}