50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
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<XRGrabInteractable>();
|
|
InitialCords = transform.localPosition;
|
|
InitialRotation = gameObject.transform.rotation;
|
|
StartCoroutine(ResetPosTimed());
|
|
//Rope = gameObject.GetComponentInChildren<Rope>();
|
|
}
|
|
|
|
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<XRGrabInteractable>().interactionManager.
|
|
//Invoke("InvokedReset", 0.1f);
|
|
//resetAsked = true;
|
|
}
|
|
|
|
}
|