Game Manager WIP
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user