コード例 #1
0
ファイル: Pump.cs プロジェクト: jhclaura/ooni-tool
    private void ExitStretchMode()
    {
        // if it's physics object
        if (m_CurrentInteractible.HasRigidbody)
        {
            // and be grabbed
            if (m_CurrentInteractible.IsGrabbing)
            {
                m_CurrentInteractible.AddJoint(m_CurrentInteractible.Grabber);
                stretchObj.GetComponent <Rigidbody> ().isKinematic = false;
            }

            if (!m_CurrentInteractible.IsKinematic)
            {
                stretchObj.GetComponent <Rigidbody> ().isKinematic = false;
            }
        }

        inStretchMode = false;
        stretchObj    = null;
    }
コード例 #2
0
ファイル: GrabnStretch.cs プロジェクト: jhclaura/ooni-tool
    public void HandleTriggerDown(object sender, ClickedEventArgs e)
    //public void HandleTriggerDown(GameObject sender)
    {
//		if(m_inSelfScalingMode && otherController.InSelfScalingSupportMode)
//		{
//			originalScale = player.localScale;
//			initialControllersDistance = (attachPoint.position - otherController.attachPoint.position).sqrMagnitude;
//			return;
//		}

        if (!inUse)
        {
            return;
        }
        else
        {
            hand.OnDown();
        }

        if (touchedObj == null)
        {
            return;                             // not possible but just double check
        }
        // if haven't grab anything && not in stretch mode
        if (!grabSomething && !inStretchMode)
        {
            // if already been grabbed
            if (m_CurrentInteractible.IsGrabbing)
            {
                // enter stretch mode!
                inStretchMode = true;
                stretchObj    = touchedObj;
                originalScale = stretchObj.transform.localScale;

                initialControllersDistance = (attachPoint.position - m_CurrentInteractible.GrabbedPos).sqrMagnitude;
                //Debug.Log (gameObject.name + "starts stretching!");
                DeviceVibrate();

                // remote the joint attached to other controller
                if (m_CurrentInteractible.Joint)
                {
                    stretchObj.GetComponent <Rigidbody> ().isKinematic = true;
                    m_CurrentInteractible.RemoveJoint();
                }
            }
            else
            {
                // be grabbed!
                m_CurrentInteractible.Down(gameObject);
                m_CurrentInteractible.grabbedPoint = attachPoint.position;

                // Grab in PHYSICS way if has rigidbody
                if (m_CurrentInteractible.TheRigidbody)                  //if (m_CurrentInteractible.HasRigidbody)
                {
                    Debug.Log("to grab r_body");
                    // set the kinematic false (if it is) so can be controlled by joint
                    if (m_CurrentInteractible.IsKinematic)
                    {
                        Debug.Log("to grab IsKinematic");
                        m_CurrentInteractible.IsKinematic = false;
                    }
                    Debug.Log("add joint");
                    // add fixed joint
                    m_CurrentInteractible.AddJoint(attachPoint);
                }
                else                 // or NON-PHYSICS(hierarchy way)
                {
                    stickerParent = touchedObj.transform.parent;
                    touchedObj.transform.parent = gameObject.transform;
                }

                grabSomething = true;
                DeviceVibrate();
            }
        }
    }