-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrecisionGrasp.cs
More file actions
43 lines (35 loc) · 1.13 KB
/
PrecisionGrasp.cs
File metadata and controls
43 lines (35 loc) · 1.13 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PrecisionGrasp : MonoBehaviour
{
public GameObject indexFing;
public GameObject thumbFing;
Rigidbody rb;
void Update()
{
bool getrb = true;
if(ContactScipt.inContact[0] && ContactScipt.inContact[1])
{
//float pinchAngle = Vector3.SignedAngle(thumbFing.transform.position, indexFing.transform.position, Vector3.up);
//Debug.Log("Obj name: " + ContactScipt.grabbedObj.name);
if (getrb)
{
ContactScipt.grabbedObj.transform.parent = transform;
rb = ContactScipt.grabbedObj.GetComponent<Rigidbody>();
rb.useGravity = false;
rb.isKinematic = true;
getrb = false;
}
}
else
{
if (ContactScipt.grabbedObj != null)
{
ContactScipt.grabbedObj.transform.parent = null;
rb.useGravity = true;
rb.isKinematic = false;
}
}
}
}