Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using UnityEngine;
- using UnityEngine.UI;
- public class OpenGate : MonoBehaviour
- {
- public bool haskey;
- public float TheDistance;
- public GameObject ActionDisplay;
- public GameObject ActionText1;
- public GameObject Gate;
- public AudioSource GateSound;
- void Update() {
- TheDistance = PlayerCasting.DistanceFromTarget;
- }
- void OnMouseOver ()
- {
- if (TheDistance < 3) {
- ActionDisplay.SetActive (true);
- ActionText1.SetActive (true);
- }
- if (Input.GetButtonDown("Action"))
- {
- if (TheDistance <= 3)
- {
- if (haskey = true)
- {
- this.GetComponent<BoxCollider>().enabled = false;
- ActionDisplay.SetActive(false);
- ActionText1.SetActive(false);
- Gate.GetComponet<Animation>().Play("OpenGate");
- GateSound.Play();
- }
- }
- }
- }
- void OnMouseExit() {
- ActionDisplay.SetActive(false);
- ActionText1.SetActive(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment