Advertisement
Atomic_Violetta

Untitled

Mar 15th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | Gaming | 0 0
  1. // Green Key Script
  2. // name
  3.  
  4. using UnityEngine;
  5.  
  6. // This is the wing cap script.
  7.  
  8. class GreenKeyScript : MonoBehaviour
  9. {
  10.  
  11.     // Something just collided with a Green Key.
  12.  
  13.     protected void OnCollisionEnter2D(Collision2D localCollision)
  14.     {
  15.         // What is the other object?
  16.         GameObject localOtherObject = localCollision.gameObject;
  17.  
  18.         // Is it Hero?
  19.  
  20.         if (localOtherObject.name.StartsWith("Hero"))
  21.         {
  22.             // Hero picks up a Greek Key by deactivating it.
  23.             this.gameObject.SetActive(false);
  24.         }
  25.     }
  26.  
  27.     // This completes the Green Key script.
  28.  
  29. }
Tags: Unity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement