void _UnMount() { body.isKinematic = false; mounted._UnMount(this); mounted = null; updateEvents.onUnMount.Invoke(); updateEvents.updateAttach.Invoke(null); }
public void TryMount(XRMountPoint newMountPoint) { if (newMountPoint.CanMount(this)) { DetachIfAttached(); UnmountIfMounted(); _Mount(newMountPoint); } }
void _Mount(XRMountPoint newMountPoint) { attachedPositionLS = transform.InverseTransformPoint(mountRef.position); attachedRotationLS = Quaternion.Inverse(transform.rotation) * mountRef.rotation; desiredPosition = newMountPoint.transform.position - desiredRotation * Quaternion.Inverse(transform.rotation) * transform.TransformVector(attachedPositionLS); desiredRotation = newMountPoint.transform.rotation * Quaternion.Inverse(attachedRotationLS); transform.position = desiredPosition; transform.rotation = desiredRotation; body.isKinematic = true; mounted = newMountPoint; newMountPoint._Mount(this); updateEvents.onMount.Invoke(); updateEvents.updateAttach.Invoke(newMountPoint.transform); Debug.Log(mounted); }