aboutsummaryrefslogtreecommitdiffstats
path: root/Assets/Scripts/RespawnPoint.cs
blob: 2a1e52e2032123b1d50292954b3c549bebcbac44 (plain)
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
using MontanaJohns.Actors;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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" && !activated)
        {
            activated = true;
            collision.gameObject.GetComponent<Player>().spawnPoint = transform.position;
            gameObject.GetComponent<SpriteRenderer>().sprite = activatedSprite;
            _audio.Play("Checkpoint");
        }
    }
}