Advertisement
johnnygoodguy2000

Checkpoint.cs

Apr 25th, 2024 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Checkpoint : MonoBehaviour
  6. {
  7.      public LevelManager levelManager;
  8.     // Start is called before the first frame update
  9.     void Start()
  10.     {
  11.         levelManager = FindAnyObjectByType<LevelManager>();
  12.     }
  13.  
  14.  
  15.     // Update is called once per frame
  16.     void Update()
  17.     {
  18.        
  19.     }
  20.  
  21.     void OnTriggerEnter2D(Collider2D other)
  22.     {
  23.         if (other.name == "Player")
  24.         {
  25.             levelManager.currentCheckpoint = gameObject;
  26.             Debug.Log("Hit Checkpoint!" + transform.position);
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement