daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2.  
  3. public class Cleaning_Mop : MonoBehaviour
  4. {
  5. #region Переменные
  6.     [SerializeField] Animator animator;
  7.  
  8.     //Private
  9.     Ray ray;
  10.     RaycastHit hit;
  11.     Vector3 center;
  12.     new Camera camera;
  13. #endregion
  14.  
  15.     private void Start()
  16.     {
  17.         camera = Camera.main;
  18.         animator = GetComponent<Animator>();
  19.         center = new Vector3(Camera.main.pixelWidth / 2, Camera.main.pixelHeight / 2, 0);
  20.     }
  21.  
  22.     private void Update()
  23.     {
  24.         if (Input.GetMouseButton(0))
  25.         {
  26.             ray = camera.ScreenPointToRay(center);
  27.             if (Physics.Raycast(ray, out hit))
  28.             {
  29.                 if (hit.transform.tag == "UsingObjects") { animator.SetBool("Clean", true); }//Попадание в объект который можно use
  30.                 else if(hit.transform.tag == "CleanerObjects" && hit.transform.GetComponent<Dirty_Objects>())
  31.                 {
  32.                     animator.SetBool("Clean", true);
  33.                     hit.transform.GetComponent<Dirty_Objects>().Clear_Ditty();
  34.                 }//Попадание в грязный объект
  35.             }
  36.             else { animator.SetBool("Clean", false); }
  37.         }
  38.         else { animator.SetBool("Clean", false); }
  39.     }
  40. }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top