コード例 #1
0
        public virtual void attach(Interactor interactor)
        {
            attachedInteractor = interactor;
#if CONF_JOINT
            ConfigurableJoint joint = gameObject.AddComponent <ConfigurableJoint>();
            joint.connectedBody = interactor.Rigid;
            //joint.spring = interactor.attachForce;
            //joint.damper = interactor.attachViscosity;
            joint.autoConfigureConnectedAnchor = false;
            joint.anchor          = Vector3.zero;
            joint.connectedAnchor = Vector3.zero;

            joint.xMotion = ConfigurableJointMotion.Limited;
            joint.yMotion = ConfigurableJointMotion.Limited;
            joint.zMotion = ConfigurableJointMotion.Limited;

            var limit = joint.linearLimitSpring;
            limit.spring            = interactor.attachForce;
            limit.damper            = interactor.attachViscosity;
            joint.linearLimitSpring = limit;
#else
            SpringConnection joint = gameObject.AddComponent <SpringConnection>();
            joint.connectedBody = interactor.Rigid;
            joint.force         = interactor.attachForce;
            joint.damping       = interactor.attachViscosity;
#endif
        }
コード例 #2
0
        public virtual void detach()
        {
#if CONF_JOINT
            ConfigurableJoint joint = gameObject.GetComponent <ConfigurableJoint>();
            if (joint == null)
            {
                return;
            }
            GameObject.Destroy(joint);
#else
            SpringConnection joint = gameObject.GetComponent <SpringConnection>();
            if (joint == null)
            {
                return;
            }
            GameObject.Destroy(joint);
#endif

            attachedInteractor = null;
        }