-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnPumpContact.cs
More file actions
74 lines (63 loc) · 1.57 KB
/
OnPumpContact.cs
File metadata and controls
74 lines (63 loc) · 1.57 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
66
67
68
69
70
71
72
73
74
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnPumpContact : MonoBehaviour
{
public GameObject RightHandPump;
public GameObject LeftHandPump;
bool unassigned = false;
bool rightHand = false;
void Start()
{
if (RightHandPump.activeInHierarchy | LeftHandPump.activeInHierarchy)
{
RightHandPump.SetActive(false);
LeftHandPump.SetActive(false);
}
string hand = PlayerPrefs.GetString("hand");
if (hand.Contains("R"))
{
rightHand = true;
}
else if (hand.Contains("L"))
{
rightHand = false;
}
else
{
rightHand = false;
}
}
void OnTriggerEnter(Collider other)
{
if(!rightHand)
{
try
{
RightHandPump.SetActive(true);
}
catch (UnassignedReferenceException e)
{
unassigned = true;
}
}
if(rightHand)
{
try
{
LeftHandPump.SetActive(true);
}
catch (UnassignedReferenceException e)
{
unassigned = true;
}
}
// Self deactivate
Collider col = gameObject.GetComponent<Collider>();
col.enabled = false;
}
void SelfDestructDelay()
{
transform.parent.gameObject.SetActive(false);
}
}