-
Notifications
You must be signed in to change notification settings - Fork 3
/
Stretch.cs
52 lines (43 loc) · 1.21 KB
/
Stretch.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Stretch : MonoBehaviour
{
public Transform index_end, thumb_end, middle_end, pinky_end, ring_end, palm;
private List<Transform> fingers = new List<Transform>();
float HandPos1 = 0, HandPos2 = 0;
// Use this for initialization
void Start()
{
fingers.Add(index_end);
fingers.Add(thumb_end);
fingers.Add(middle_end);
fingers.Add(ring_end);
fingers.Add(pinky_end);
}
// Update is called once per frame
void Update()
{
//Debug.Log(Vector3.Distance(palm.position, pinky_end.position));
// Debug.Log(GetHandPos());
if (HandPos1 == 0)
{
HandPos1 = HandPos2 = GetHandPos();
}
else
{
HandPos1 = Mathf.Max(GetHandPos(), HandPos1);
HandPos2 = Mathf.Min(GetHandPos(), HandPos2);
}
Debug.Log(100*(HandPos1 - HandPos2)/0.31f);
}
float GetHandPos()
{
float sumVecs = 0;
foreach(Transform fing in fingers)
{
sumVecs += Vector3.Distance(fing.position,palm.position);
}
return sumVecs;
}
}