-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckpoint.cs
36 lines (28 loc) · 1.06 KB
/
Checkpoint.cs
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
36
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Checkpoint : MonoBehaviour
{
//Setting if the checkpoint has been activated or not - to prevent falling onto a farther down one
public bool Awakened = false;
public ParticleSystem activationEffectUpper;
public ParticleSystem activationEffectLower;
void Start()
{
activationEffectUpper.Pause();
activationEffectLower.Pause();
}
private void OnTriggerEnter(Collider collision)
{
//If new checkpoint and interacted with player mark as new spawn location and change colors
if((collision.transform.tag == "Player") && (Awakened == false))
{
PlayerController.LastCheckPointPos = transform.position;
Debug.Log("Checkpoint Aquired");
GetComponent<Renderer>().material.color = new Color(255, 255, 255);
Awakened = true;
activationEffectUpper.Play();
activationEffectLower.Play();
}
}
}