Advertisement
evelynshilosky

WaterSystem - Part 1

Jan 21st, 2025
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class WaterSystem : MonoBehaviour
  6. {
  7.     public static WaterSystem Instance { get; private set; }
  8.     public float waterLevel = 0f; // Set this in the inspector
  9.  
  10.     private void Awake()
  11.     {
  12.         if (Instance == null)
  13.         {
  14.             Instance = this;
  15.             DontDestroyOnLoad(gameObject);
  16.         }
  17.         else
  18.         {
  19.             Destroy(gameObject);
  20.         }
  21.     }
  22.  
  23.     public bool IsUnderwater(Vector3 position)
  24.     {
  25.         return position.y < waterLevel;
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement