-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckPoint.cs
More file actions
35 lines (32 loc) · 963 Bytes
/
CheckPoint.cs
File metadata and controls
35 lines (32 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CheckPoint : MonoBehaviour
{
private SpawnManager spawnManager;
int totalCP;
private void Start()
{
spawnManager = GameObject.Find("SpawnManager").GetComponent<SpawnManager>();
if(spawnManager == null)
{
Debug.LogError("Spawn Manager is null");
}
}
private void OnTriggerExit(Collider other)
{
if (other.tag == "Player")
{
spawnManager.SpawnCheckPoint();
spawnManager.checkPointNum++;
if (PlayerPrefs.HasKey("TotalCP"))
{
totalCP = PlayerPrefs.GetInt("TotalCP");
}
totalCP++;
PlayerPrefs.SetInt("TotalCP", totalCP);
spawnManager.totalCPText.text = totalCP.ToString();
Destroy(this.gameObject, 0.5f);
}
}
}