Repository navigation
Expand file tree
/
Copy pathLightFire.cs
More file actions
65 lines (58 loc) · 1.59 KB
/
Copy pathLightFire.cs
File metadata and controls
65 lines (58 loc) · 1.59 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Collections;
using System.Collections.Generic;
using System.Runtime.ExceptionServices;
using UnityEngine;
public class LightFire : MonoBehaviour
{
public GameObject ext;
public GameObject fire;
public GameObject blocker;
public bool isExtinguish = false;
public bool inReach;
public GameObject ExtinguishText;
public AudioSource ExtSound;
void Start(){
inReach = false;
ExtinguishText.SetActive(false);
blocker.SetActive(true);
fire.SetActive(true);
}
void OnTriggerEnter(Collider other){
if (other.gameObject.tag == "Reach" && !isExtinguish && ext.activeInHierarchy)
{
inReach = true;
ExtinguishText.SetActive(true);
}
else if (other.gameObject.tag == "Reach" && isExtinguish )
{
inReach = true;
ExtinguishText.SetActive(false);
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Reach")
{
inReach = false;
ExtinguishText.SetActive(false);
}
}
void Update(){
if (!isExtinguish && inReach && Input.GetButtonDown("Interact")&& ext.activeInHierarchy)
{
isExtinguish = true;
ExtinguishText.SetActive(false);
inReach = false;
ExtSound.Play();
Invoke("disablefire", 2f);
}
else if (isExtinguish)
{
ExtinguishText.SetActive(false);
}
}
void disablefire(){
blocker.SetActive(false);
fire.SetActive(false);
}
}