Ejemplo n.º 1
0
    private void SnapobjectToController(object sender, ControllerInteractionEventArgs e)
    {
        //get formulaController for sure
        formulaController = GetComponent <FormulaController>();
        formulaController.callibrate();

        //disable softbody script when touching with controller to be grabbable
        try
        {
            TxSoftBody softRB = this.touchingObject.GetComponent <TxSoftBody>();
            softRB.enabled = false;
        } catch (Exception error)
        {
            Debug.Log(error.StackTrace.ToString());
        }
        GameObject        throwable     = null;
        GameObject        grabbedObject = GameObject.Find("grabbedObject");
        VRTK_InteractGrab grab          = GetComponent <VRTK_InteractGrab>();

        try
        {
            foreach (Transform child in grabbedObject.transform)
            {
                throwable = child.gameObject;
                throwable.transform.parent = null;
                throwable.transform.SetParent(GC.transform);
                throwable.transform.position = transform.position;
                throwable.GetComponent <Rigidbody>().isKinematic = false;
                grab.AttemptGrab();
                this.grabbedGo = throwable;

                OnGrabbed(throwable, new Vector3());
            }
        }
        catch (Exception error)
        {
            Debug.LogWarning("Can not snap object to right controller - " + error.ToString());
        }
    }