Train-of-Thought/Assets/Scripts/Checkpoint.cs
Gerard Gascón 862afc9b7a init
2025-04-24 16:56:52 +02:00

33 lines
874 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Checkpoint : MonoBehaviour
{
Animator anim;
bool active;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player" && !active)
{
AudioManager.instance.Play("Checkpoint");
anim.SetBool("Active", true);
Debug.Log("Checkpoint at X" + transform.position.x + " Y" + transform.position.y);
collision.GetComponent<PlayerStats>().checkpoint = transform.position;
collision.GetComponent<PlayerStats>().checkpoint.y += 1;
active = true;
}
}
}