Advertisement
JakSilver

Untitled

Nov 16th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class OpenGate : MonoBehaviour
  7. {
  8. public bool haskey;
  9. public float TheDistance;
  10. public GameObject ActionDisplay;
  11. public GameObject ActionText1;
  12. public GameObject Gate;
  13. public AudioSource GateSound;
  14. void Update()
  15. {
  16. TheDistance = PlayerCasting.DistanceFromTarget;
  17. }
  18. void OnMouseOver()
  19. {
  20. if (TheDistance < 3)
  21. {
  22. ActionDisplay.SetActive(true);
  23. ActionText1.SetActive(true);
  24. }
  25. if (Input.GetButtonDown("Action"))
  26. {
  27. if (TheDistance <= 3)
  28. {
  29. if (haskey = true)
  30. {
  31. ActionDisplay.SetActive(false);
  32. ActionText1.SetActive(false);
  33. Gate.GetComponet<Animation>().Play("OpenGate");
  34. GateSound.Play();
  35. }
  36. }
  37. }
  38. }
  39. void OnMouseExit()
  40. {
  41. ActionDisplay.SetActive(false);
  42. ActionText1.SetActive(false);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement