Advertisement
johnnygoodguy2000

PipeMiddleScript

Mar 17th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PipeMiddleScript : MonoBehaviour
  6. {
  7.     public LogicScript logic;
  8.  
  9.     void Start()
  10.     {
  11.         logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
  12.     }
  13.  
  14.     // OnTriggerEnter2D is called when the attached Collider2D component
  15.     // detects a trigger collision.
  16.     private void OnTriggerEnter2D(Collider2D collision)
  17.     {
  18.         if (collision.CompareTag("Player")) // Check if the collided object is the bird
  19.         {
  20.             logic.addScore(1);
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement