using UnityEngine; public class Cleaning_Mop : MonoBehaviour { #region Переменные [SerializeField] Animator animator; //Private Ray ray; RaycastHit hit; Vector3 center; new Camera camera; #endregion private void Start() { camera = Camera.main; animator = GetComponent(); center = new Vector3(Camera.main.pixelWidth / 2, Camera.main.pixelHeight / 2, 0); } private void Update() { if (Input.GetMouseButton(0)) { ray = camera.ScreenPointToRay(center); if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "UsingObjects") { animator.SetBool("Clean", true); }//Попадание в объект который можно use else if(hit.transform.tag == "CleanerObjects" && hit.transform.GetComponent()) { animator.SetBool("Clean", true); hit.transform.GetComponent().Clear_Ditty(); }//Попадание в грязный объект } else { animator.SetBool("Clean", false); } } else { animator.SetBool("Clean", false); } } }