using GogoGaga.OptimizedRopesAndCables; using System.Collections; using UnityEngine; using UnityEngine.XR.Interaction.Toolkit.Interactables; public class MaterialRopeDetachAction : MonoBehaviour { [SerializeField] Vector3 InitialCords; [SerializeField] Quaternion InitialRotation; bool resetAsked = false; XRGrabInteractable grabComponent; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { grabComponent = gameObject.GetComponent(); InitialCords = transform.localPosition; InitialRotation = gameObject.transform.rotation; StartCoroutine(ResetPosTimed()); //Rope = gameObject.GetComponentInChildren(); } IEnumerator ResetPosTimed() { yield return new WaitForFixedUpdate(); if (!grabComponent.isSelected) { transform.localPosition = InitialCords; transform.rotation = InitialRotation; } StartCoroutine(ResetPosTimed()); } public void ResetPos() { transform.localPosition = InitialCords; transform.rotation = InitialRotation; //Rope.RecalculateRope(); // gameObject.GetComponent().interactionManager. //Invoke("InvokedReset", 0.1f); //resetAsked = true; } }