22-10-2021, 04:07 AM
(This post was last modified: 22-10-2021, 04:14 AM by sangku2000.)
Thanks for your advise! It perfectly work!
↓ this is my code!
public class RopeStrain : MonoBehaviour
{
ObiRopeCursor cursor;
ObiRope rope;
public Transform attachmentStart;
public Transform attachmentEnd;
public float distanceRate = 0.45f;
// Start is called before the first frame update
void Start()
{
rope = GetComponent<ObiRope>();
cursor = GetComponent<ObiRopeCursor>();
}
// Update is called once per frame
void LateUpdate()
{
AdjustStrain();
}
private void AdjustStrain()
{
if (attachmentStart == null || attachmentEnd == null)
{
#if UNITY_EDITOR
Debug.Log("transform null...!!!");
#endif
return;
}
cursor.ChangeLength(Vector3.Distance(attachmentStart.transform.position, attachmentEnd.transform.position) * distanceRate * Time.deltaTime);
// length is adjusted by rate and time.
}
But.... I think self collider is seem to be not working...
I think i need to recalculate the element.. is right?
↓ this is my code!
public class RopeStrain : MonoBehaviour
{
ObiRopeCursor cursor;
ObiRope rope;
public Transform attachmentStart;
public Transform attachmentEnd;
public float distanceRate = 0.45f;
// Start is called before the first frame update
void Start()
{
rope = GetComponent<ObiRope>();
cursor = GetComponent<ObiRopeCursor>();
}
// Update is called once per frame
void LateUpdate()
{
AdjustStrain();
}
private void AdjustStrain()
{
if (attachmentStart == null || attachmentEnd == null)
{
#if UNITY_EDITOR
Debug.Log("transform null...!!!");
#endif
return;
}
cursor.ChangeLength(Vector3.Distance(attachmentStart.transform.position, attachmentEnd.transform.position) * distanceRate * Time.deltaTime);
// length is adjusted by rate and time.
}
But.... I think self collider is seem to be not working...
I think i need to recalculate the element.. is right?