-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectCombiner.cs
More file actions
50 lines (41 loc) · 1.56 KB
/
ObjectCombiner.cs
File metadata and controls
50 lines (41 loc) · 1.56 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectCombiner : MonoBehaviour {
private Collider obj1;
private Collider obj2;
private int counter = 0;
private Collider obj2Collider;
private void OnTriggerEnter(Collider other)
{
if (counter == 0 && other.gameObject.layer == LayerMask.NameToLayer("GraspableObjects"))
{
obj1 = other;
counter++;
Debug.Log("Object 1 assigned");
}
else if (counter == 1 && other.gameObject.layer == LayerMask.NameToLayer("GraspableObjects"))
{
other.transform.parent = obj1.transform;
other.attachedRigidbody.useGravity = false;
other.attachedRigidbody.isKinematic = true;
other.enabled = false;
other.transform.position = obj1.transform.position;
other.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 45.0f, 45.0f));
//obj2Collider = obj2.GetComponent<Collider>();
counter++;
Debug.Log("Object 2 assigned");
counter = 0;
Debug.Log("Counter reset");
CombineObjects();
}
}
private void CombineObjects()
{
//obj2.enabled = false;
//obj2.transform.parent = obj1.transform;
//obj2.transform.position = obj1.transform.position;
//obj2.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 45.0f, 45.0f));
Debug.Log("Objects combined");
}
}