SHARE
TWEET
Untitled
a guest
Jan 29th, 2018
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- 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<Animator>();
- 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<Dirty_Objects>())
- {
- animator.SetBool("Clean", true);
- hit.transform.GetComponent<Dirty_Objects>().Clear_Ditty();
- }//Попадание в грязный объект
- }
- else { animator.SetBool("Clean", false); }
- }
- else { animator.SetBool("Clean", false); }
- }
- }
RAW Paste Data

