Advertisement
Guest User

code

a guest
Aug 20th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine;
  5.  
  6. public class DoorCellDistance : MonoBehaviour
  7. {
  8. public float TheDistance;
  9. public GameObject ActionDisplay;
  10. public GameObject ActionText;
  11. public GameObject TheDoor;
  12. public AudioSource CreakSound;
  13. public AudioSource CreakSoundClose;
  14.  
  15.  
  16. void Update()
  17. {
  18. TheDistance = PlayerCasting.DistanceFromTarget;
  19.  
  20. }
  21.  
  22. void OnMouseOver()
  23. {
  24. if (TheDistance <= 1)
  25. {
  26. ActionDisplay.SetActive(true);
  27. ActionText.SetActive(true);
  28.  
  29. }
  30. if (Input.GetButtonDown("Action"))
  31. {
  32. if (TheDistance <= 1)
  33. {
  34. this.GetComponent<BoxCollider>().enabled = false;
  35. ActionDisplay.SetActive(false);
  36. ActionText.SetActive(false);
  37. TheDoor.GetComponent<Animation> ().Play ("DoorOpen001");
  38. CreakSound.Play();
  39.  
  40. StartCoroutine(DoorClose());
  41.  
  42. }
  43. }
  44. }
  45. void OnMouseExit()
  46. {
  47. ActionDisplay.SetActive(false);
  48. ActionText.SetActive(false);
  49. }
  50. IEnumerator DoorClose ()
  51.  
  52. {
  53. yield return new WaitForSeconds(7);
  54. TheDoor.GetComponent<Animation>().Play("DoorClose001");
  55. CreakSoundClose.Play();
  56. yield return new WaitForSeconds(0);
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement