using System.Collections.Generic; using UnityEngine; [System.Serializable] public class Rope { public List points { get ; private set; } public List sticks { get; private set; } public Rope(List points, List sticks) { this.points = points; this.sticks = sticks; } public float CalculateLengthOvershoot() { float sum = 0f; foreach (Stick stick in sticks) { Debug.DrawRay(stick.B.position, (stick.A.position - stick.B.position).normalized * stick.desiredLength); float dist = Vector3.Distance(stick.A.position, stick.B.position); sum += dist - stick.desiredLength; } return sum; } }