protected override void OnLockedPlugUngrabbed(object sender, InteractableObjectEventArgs args) { StopSnapping(); LockedPlug.ConnectToDataEndpoint(plugReceptacle); plugAttach.transform.position = targetPosition; plugAttach.transform.rotation = targetRotation; LockedPlug.GetComponent <VRTK_TransformFollow>().gameObjectToFollow = plugAttach; }
/// <summary> /// Moves the plug to the socket's connection point and connects the plug to the socket /// </summary> /// <returns></returns> private IEnumerator AutoPlugIntoTarget() { LockedPlug.DestinationEndpoint = plugReceptacle; StopSnapping(); positionSnap.SnapToTarget(PlugConnectionPoint.position, 1f); while (!positionSnap.HasReachedTarget) { yield return(new WaitForEndOfFrame()); } LockedPlug.ConnectToDataEndpoint(plugReceptacle); LockedPlug.GetComponent <VRTK_TransformFollow>().gameObjectToFollow = PlugConnectionPoint.gameObject; yield return(null); }