示例#1
0
        public void Disconnect()
        {
            if (!IsFree)
            {
                Debug.Log("UnJoint Invoked!");
                IsFree = true;

                JointBehaviour.RemoveDisconnectedJoint(_connectedWrapper, ConnectedJointPoint.JointBehaviour);

                ConnectedJointPoint.Disconnect();
                ConnectedJointPoint = null;
                _connectedWrapper = null;

                if (_fixedJoint != null)
                {
                    Destroy(_fixedJoint);
                }

                Rigidbody behaviourBody = JointBehaviour.GetComponent<Rigidbody>();

                if (behaviourBody != null)
                {
                    behaviourBody.WakeUp();
                }
            }
        }
示例#2
0
        public void UnLock()
        {
            if (IsLocked)
            {
                Debug.Log("UnLock Invoked!");

                IsLocked = false;

                if (_configurableJoint != null)
                {
                    Destroy(_configurableJoint);
                }

                if (ConnectedJointPoint != null)
                {
                    ConnectedJointPoint.UnLock();
                }
            }
        }
示例#3
0
        public void Lock(bool sender = true)
        {
            if (!IsLocked && !IsFree)
            {
                IsLocked = true;

                if (_fixedJoint != null)
                {
                    Destroy(_fixedJoint);
                }

                if (sender)
                {
                    if (_connectedGameObject != null)
                    {
                        var jointConnectedBody = _connectedGameObject.GetComponent<Rigidbody>();

                        if (jointConnectedBody != null && !jointConnectedBody.isKinematic)
                        {
                            _configurableJoint = JointBehaviour.CreateJoint();
                            _configurableJoint.connectedBody = jointConnectedBody;
                        }
                    }

                }

                if (ConnectedJointPoint != null)
                {
                    ConnectedJointPoint.Lock(false);
                }
                else
                {
                    Debug.Log("Canditate point is null! Unlock!");
                    UnLock();
                }

            }
        }