Advertisement
johnnygoodguy2000

ExtraLife.cs

May 12th, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ExtraLife : MonoBehaviour
  6. {
  7.  
  8.     private LifeManager lifeStystem;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.         lifeStystem = FindObjectOfType<LifeManager>();
  13.        
  14.     }
  15.  
  16.    void OnTriggerEnter2D(Collider2D other)
  17.     {
  18.         if (other.name == "Player")
  19.         {
  20.             lifeStystem.AddLife();
  21.  
  22.             Destroy(gameObject);
  23.         }
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement