]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Maus/Checkpoint.cs
Checkpoint-System v0.2
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / Checkpoint.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class Checkpoint : MonoBehaviour
6 {
7     private CheckpointManager cm;
8
9     public Sprite red;
10     public Sprite green;
11
12     void Start()
13     {
14         cm = GameObject.FindGameObjectWithTag("CheckpointManager").GetComponent<CheckpointManager>();
15     }
16
17     void OnTriggerEnter2D(Collider2D collision)
18     {
19         if(collision.CompareTag("Player"))
20         {
21             cm.lastCheckpointPos = transform.position;
22             GetComponent<SpriteRenderer>().sprite = green;
23         }
24     }
25 }