private IEnumerator CheckCollisionRelease(GameObject handObject, GameObject factoryObject, Interactable currentInteractable)
    {
        yield return(null);

        Interactable handInteractable = Interactable.GetInteractable(handObject.transform);

        while (MultiColliderTool.CheckCollision(handObject, factoryObject))
        {
            if (currentInteractable != interactable)
            {
                handInteractable.DestroyInteractable();
                yield break;
            }

            if (!handInteractable.IsGrabbed)
            {
                handInteractable.DestroyInteractable();
                yield break;
            }

            yield return(null);
        }

        CollisionIgnore.IgnoreCollisions(handObject.transform, factoryObject.transform, false);
    }
    private void CreateNewCopy()
    {
        GameObject handObject = LatestCopy;

        if (LatestCopy != null)
        {
            triggerColliderCount.SetInteractable(handObject);

            if (LatestCopy.GetComponent <Rigidbody>().isKinematic == true)
            {
                Destroy(LatestCopy);
            }
        }

        LatestCopy = Instantiate(CopyObject);
        LatestCopy.transform.position = transform.position;

        interactable = LatestCopy.GetComponent <Interactable>();
        LatestCopy.SetActive(true);

        if (handObject != null)
        {
            CollisionIgnore.IgnoreCollisions(handObject.transform, LatestCopy.transform, true);
            StartCoroutine(CheckCollisionRelease(handObject, LatestCopy, interactable));
        }

        lastPicked = handObject;
    }
Exemple #3
0
 private void IgnoreCollisions(Transform[] items, bool ignore)
 {
     for (int i = 0; i < items.Length; i++)
     {
         for (int j = 0; j < items.Length; j++)
         {
             if (i != j)
             {
                 CollisionIgnore.IgnoreCollisions(items[i], items[j], ignore);
             }
         }
     }
 }