-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowQuest.cs
46 lines (44 loc) · 1.21 KB
/
ShowQuest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShowQuest : MonoBehaviour
{
public GameObject questUI;
private int collision = 0;
public AudioClip sound;
private AudioSource audio;
private bool alreadyPlayed = false;
void Start()
{
audio = GetComponent<AudioSource>();
questUI.SetActive(false);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player" && questUI.activeSelf == false && collision == 0 && alreadyPlayed == false)
questUI.SetActive(true);
audio.PlayOneShot(sound, 5);
alreadyPlayed = true;
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
questUI.SetActive(false);
collision = 1;
}
void Update()
{
if (Input.GetButton("Q") && collision == 1)
{
questUI.SetActive(true);
if (Input.GetButtonDown("Q"))
{
audio.PlayOneShot(sound, 5);
}
}
if (Input.GetButtonUp("Q") && collision == 1)
{
questUI.SetActive(false);
}
}
}