aboutsummaryrefslogtreecommitdiffstats
path: root/Assets/Scripts/RespawnPoint.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/RespawnPoint.cs')
-rw-r--r--Assets/Scripts/RespawnPoint.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/Assets/Scripts/RespawnPoint.cs b/Assets/Scripts/RespawnPoint.cs
index 6396128..2a1e52e 100644
--- a/Assets/Scripts/RespawnPoint.cs
+++ b/Assets/Scripts/RespawnPoint.cs
@@ -7,12 +7,22 @@ public class RespawnPoint : MonoBehaviour
{
[SerializeField] private Sprite activatedSprite;
+ private AudioManager _audio;
+ private bool activated;
+
+ private void Start()
+ {
+ _audio = FindObjectOfType<AudioManager>();
+ }
+
private void OnTriggerEnter2D(Collider2D collision)
{
- if (collision.gameObject.tag == "Player")
+ if (collision.gameObject.tag == "Player" && !activated)
{
+ activated = true;
collision.gameObject.GetComponent<Player>().spawnPoint = transform.position;
gameObject.GetComponent<SpriteRenderer>().sprite = activatedSprite;
+ _audio.Play("Checkpoint");
}
}
}