-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConjure.cs
85 lines (77 loc) · 3.08 KB
/
Conjure.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using UnityEngine;
using System.Collections;
using Leap;
using System.Collections.Generic;
using Leap.Unity;
public class Conjure : MonoBehaviour
{
Leap.Controller controller;
// Use this for initialization
void Start()
{
controller = new Controller();
}
// Update is called once per frame
public bool isConjured = false;
public GameObject temp;
float nextFire = 0.0f;
int counter = 0;
void Update()
{
{
Frame frame = controller.Frame();
if (frame.Hands.Count == 2)
{
List<Hand> hands = frame.Hands;
Hand one = hands[0];
Hand two = hands[1];
//Debug.Log(one.PinchDistance);
if (one.PinchDistance < 20 && two.PinchDistance < 20 && !isConjured)
{
GameObject eye = GameObject.Find("LeapHandController");
EyeOfA eyeA = eye.GetComponent<EyeOfA>();
GameObject a = eyeA.eyeOfA;
temp = GameObject.Instantiate(a) as GameObject;
temp.transform.localScale = new Vector3(0.02f, 0.02f, 0.02f);
temp.transform.Rotate(90, 0, 0);
temp.transform.position = new Vector3(0, 0, 1);
isConjured = true;
}
else if (one.PinchDistance < 20 && two.PinchDistance < 20 && isConjured)
{
temp.transform.Rotate(0, 0, 2);
if (temp.transform.localScale.x < 0.3f)
{
temp.transform.localScale += new Vector3(0.002f, 0.002f, 0.002f);
}
else
{
if (Time.time > nextFire && counter < 10)
{
counter++;
GameObject clyinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
clyinder.transform.position.Set(0, 0, 3);
clyinder.transform.Rotate(90, 0, 0);
Vector3 scale = transform.localScale;
scale.x = 0.2f;
scale.y = 0.2f;
scale.z = 0.2f;
clyinder.transform.localScale = scale;
Rigidbody clyinderRigid = clyinder.AddComponent<Rigidbody>().GetComponent<Rigidbody>();
clyinderRigid.useGravity = false;
clyinderRigid.AddForce(transform.forward * 500);
Destroy(clyinder, 2f);
nextFire = Time.time + 0.2f;
}
}
}
else
{
Destroy(temp);
isConjured = false;
counter = 0;
}
}
}
}
}