void Release() { if (m_grabbed) { m_grabbed.Grab(false); grabbedJoint.onJointBreak.RemoveListener(Release); grabbedJoint.RemoveJoint(); if (grabbedJoint.rigidbody) { grabbedJoint.rigidbody.velocity = m_inputManager.GetVelocity(); grabbedJoint.rigidbody.angularVelocity = m_inputManager.GetAngularVelocity(); } grabbedJoint.onJointBreak.RemoveListener(Release); m_telekinesis.Active = true; m_handAnimator.SetBool("Visible", true); m_handAnimator.SetBool("Attract", false); m_onReleaseInteractable.Invoke(m_grabbed); m_setup.NotifyRelease(m_grabbed); m_grabbed = null; // ObjectInTrigger = null; } }
public void Grab(MTK_Interactable obj) { if (obj) { // if(!obj.GetComponent<ScaleEffect>() && !obj.GetComponent<IcoSegment>()) // obj.transform.position = transform.position; if (obj.jointType.Used()) { obj.jointType.RemoveJoint(); } obj.jointType.onJointBreak.AddListener(Release); if (!obj.jointType.JoinWith(gameObject)) { obj.jointType.onJointBreak.RemoveListener(Release); return; } obj.Grab(true); m_grabbed = obj; grabbedJoint = obj.jointType; inputManager.Haptic(1); m_telekinesis.Active = false; m_handAnimator.SetBool("Visible", false); m_handAnimator.SetBool("Attract", true); m_setup.NotifyGrab(m_grabbed); // ObjectInTrigger = null; } }