Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to give a tension to rope...
#5
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?


Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
How to give a tension to rope... - by sangku2000 - 20-10-2021, 03:27 AM
RE: How to give a tension to rope... - by sangku2000 - 22-10-2021, 04:07 AM