forked from ErigoLee/HandTrackingGrab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PartDetector.cs
58 lines (48 loc) · 1.61 KB
/
PartDetector.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
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PartDetector : MonoBehaviour
{
public PartActive partActive;
private GameObject[] pointers;
[SerializeField] private DecoManager decoManager;
private bool missionClear = false;
void Start()
{
pointers = GameObject.FindGameObjectsWithTag("Pointer");
foreach (GameObject pointer in pointers)
{
pointer.SetActive(false);
}
}
public void OnTriggerEnter(Collider otherCollider)
{
if (otherCollider.gameObject.tag == "NPC_part")
{
Debug.Log("Part check!!");
GameObject npc_part = GameObject.FindWithTag("NPC_part");
OVRGrabbable npc_grabble = npc_part.GetComponent<OVRGrabbable>();
OVRGrabber npc_grabber = npc_grabble.grabbedBy;
GameObject leftHand = GameObject.FindWithTag("LeftHand");
GameObject rightHand = GameObject.FindWithTag("RightHand");
if (npc_grabber.gameObject == leftHand)
{
npc_part.GetComponent<PartDestroy>().SetDestroy("LeftHand");
}
if (npc_grabber.gameObject == rightHand)
{
npc_part.GetComponent<PartDestroy>().SetDestroy("RightHand");
}
foreach (GameObject pointer in pointers)
{
pointer.SetActive(true);
}
partActive.FixedArm();
if (!missionClear)
{
decoManager.StartStep1_1();
missionClear = true;
}
}
}
}